【发布时间】:2019-07-31 23:47:09
【问题描述】:
从 excel 表生成 pdf 时出现以下错误:
ws.ExportAsFixedFormat(0, save_as)
File "<COMObject <unknown>>", line 5, in ExportAsFixedFormat
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024809), None)
下面是我的代码:
pythoncom.CoInitialize()
xlApp = client.Dispatch("Excel.Application")
logging.debug("Saving excel file {} to file {}".format(filename, save_as))
books = xlApp.Workbooks.Open(filename)
ws = books.Worksheets[0]
ws.Visible = 1
ws.ExportAsFixedFormat(0, save_as)
books.Close(True)
xlApp.Quit()
它可以在我安装了 Office 365 的笔记本电脑上运行,但是在安装了 Microsoft Office 2007 的另一个系统上出现上述错误。
Python 版本:python 2.7
openpyxl : 2.4.5
pywin32: 224
没有足够的文档。如果有人可以提供调试它并理解错误的指针,那将是非常有帮助的。
【问题讨论】: