【发布时间】:2017-10-05 14:40:38
【问题描述】:
所以我是并行处理的新手,但我开始让它同时解析多个 Excel 文件。当我只使用 openpyxl 时它工作得很好,但据我了解,这是一个基本的 XML 解析器。当我包含使用 XLWings 的部分时(我喜欢利用它在 Excel 中评估方程式以进行文件验证的能力),我收到以下错误:
pywintypes.com_error: (-2147221008, 'CoInitialize has not been called.', None, None)
这大致是我用来初始化新的 XLWings 实例并加载工作簿的代码:
def openWorkbook(self, filePath):
app = xw.apps.add()
app.display_alerts = False
app.screen_updating = False
wb = self.app.books(filePath) #Note that this is called only once for each workbook.
app.screen_updating = True
app.quit()
有没有办法让 XLWings 同时打开多个 Excel 实例?我应该尝试做类似this 的事情吗?如果是这样,我不确定初始化如何将线程交给 XLWings。
【问题讨论】:
标签: python parallel-processing xlwings