0

I have an excel sheet which i want to convert to Python. Need recommendation in suggesting package or a module for above query.

i have tried with PDFWriter. I am using pandas to read my excel file and inputing that dataset to PDFwriter to create pdf file. The output pdf seems blank.

import pandas as pd
from pdfrw import PdfWriter

wb = pd.read_excel('excel file path')

wb=PdfWriter()

wb.write('result.pdf')

The pdf file created in of 1kb only..

Rajan Sharma
  • 2,211
  • 3
  • 21
  • 33
Ketan
  • 1
  • 1
  • 1
  • 2

2 Answers2

2
import pandas as pd
import pdfkit
df = pd.read_excel("file.xlsx")#input
df.to_html("file.html")#to html
pdfkit.from_file("file.html", "file.pdf")#to pdf
0

Here are few points :

  1. You are reading the DataFrame in a variable wb in first line and overwriting the same variable in next line. The values read from the excel sheet will be lost.
  2. You have to use addpage() function to add content to your page.

You can also try this link.

Deepak Patankar
  • 3,076
  • 3
  • 16
  • 35