在Excel中将excel转换为pdf

有没有一个好的Python模块转换.xls文件为PDF?

试试xtopdf 。

请注意,有一些限制:

只支持包含纯文本内容的简单电子表格,例如string,数字和date。 带有格式化单元格(粗体,斜体,右alignment等)或embedded式图像的电子表格不受支持,或者格式和图像可能在PDF输出中丢失。 对此input格式的支持意味着您可以将您的电子表格发布为PDF。

我知道这是超级老,但unoconv工程。 例如, unoconv -f pdf your_excel.xls 。 请注意,它只是要求开放式办公室来做实际的转换。

http://dag.wieers.com/home-made/unoconv/

FileFormat = 57 …作为脆弱的ExportAsFixedFormat的替代scheme…

 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()