I have created .xls using xlwt module. Now i want to convert this newly created xls file to pdf. Can anyone please tell me how can i do this through python scripting. Am using python 2.6 version.
There are at least two possibilities here: either you read the .xls
back in as cells and generate a PDF, or maybe you want to print the .xls
to .pdf
from the program that just created the .xls
.
In the first case you might want to consider writing the .pdf
directly (you have the data to make the .xls
in the program at some point). I have a grid class that can be written out in HTML format, or to .xls' (using
xlwt ),
.xlsm (using
openpyxl ) and to
.pdf (using
reportlab`).
You will need to use the second option if you write formula and that kind of stuff in your .xls
and want to have the calculated results in your .pdf
. In that case use subprocess to call Microsoft Excel
or OpenOffice/LibreOffice Calc
with the right commandline parameters for printing/converting the file to PDF.
Eg for LibreOffice 4.0 the commandline would be:
scalc --convert-to pdf yourfile.xls
which will result in a yourfile.pdf
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.