问题
Is there a good python module to convert .xls file to PDF?
回答1:
Try xtopdf.
Note that there are some limitations:
Only simple spreadsheets that have plain text content, such as strings, numbers and dates, are supported. Spreadsheets with formatted cells (bold, italic, right-justified, etc.) or embedded images are not supported, or the formatting and images may be lost in the PDF output. Support for this input format means that you can publish your spreadsheets as PDF.
回答2:
I know this is super old, but unoconv works. E.g., unoconv -f pdf your_excel.xls
. Note its just calling open office to do the actual conversion.
http://dag.wieers.com/home-made/unoconv/
回答3:
FileFormat = 57... as an alternative to the fragile ExportAsFixedFormat...
from win32com import client
import win32api
def exceltopdf(doc):
excel = client.DispatchEx("Excel.Application")
excel.Visible = 0
wb = excel.Workbooks.Open(doc)
ws = wb.Worksheets[1]
try:
wb.SaveAs('c:\\targetfolder\\result.pdf', FileFormat=57)
except Exception, e:
print "Failed to convert"
print str(e)
finally:
wb.Close()
excel.Quit()
来源:https://stackoverflow.com/questions/2018932/convert-excel-to-pdf-in-python