简体   繁体   中英

python - how to create pdf from excel file created using xlwt

I am creating reports in MS Excel format and have been serving them to users using xlwt and related modules in python.

I would like to serve PDFs of these Excel files as well. I have looked at PyPDF and ReportLab, but couldn't figure out how to convert my xlwt excel files to PDFs.

I was thinking maybe I could save the xlwt to StringIO and then convert it to PDF? Is there any python module that does that?

What options do I have?

Well, it depends that from where you are fetching the data and in what form. What I mean to say is that its not necessary that you first use xlwt to generate excel file and then generate pdf from it. You can also generate PDF directly from the source in parallel.

There are several modules for generating PDFs depending on the source/form of data that is to be converted. Like PISA is to convert Tables/Data present in HTML form into PDF. It uses ReportLab Toolkit, the HTML5lib and pyPdf together and pretty easy to use. Its documentation is available Here . PISA is getting popular with Django applications integrating it for PDF generation.

You may find this helpful. There list of python modules for PDF generation which can be found HERE for different types of requirements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM