pywintypes.com_error: (-2147352567, '发生意外。', (0, None, None, None, 0, -2146827284), None)

通过 xlwings操作生成excel时意外报错(pywintypes.com_error: (-2147352567, '发生意外。', (0, None, None, None, 0, -2146827284), None))

详细报错信息如下:

Traceback (most recent call last):
  File "sanity_report.py", line 136, in <module>
    report.generate_report("HAHADAXIAO", "XIAO", "23850", "V1.0.0", [2, 0, 0, 0])
  File "sanity_report.py", line 40, in generate_report
    sht.range("B3:C3").merge()
  File "C:\Program Files\Python37\lib\site-packages\xlwings\main.py", line 1905, in merge
    self.impl.merge(across)
  File "C:\Program Files\Python37\lib\site-packages\xlwings\_xlwindows.py", line 1050, in merge
    self.xl.Merge(across)
  File "C:\Program Files\Python37\lib\site-packages\xlwings\_xlwindows.py", line 66, in __call__
    v = self.__method(*args, **kwargs)
  File "C:\Users\ADMIN\AppData\Local\Temp\gen_py\3.7\00020813-0000-0000-C000-000000000046x0x1x8.py", line 31848, in Merge
    return self._oleobj_.InvokeTypes(564, LCID, 1, (24, 0), ((12, 17),),Across
pywintypes.com_error: (-2147352567, '发生意外。', (0, None, None, None, 0, -2146827284), None)

 

针对以上错误代码,查询错误的详细描述:

>>> import win32api
>>> win32api.FormatMessage(-2146827284)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pywintypes.error: (317, 'FormatMessageW', '系统无法在消息文件中为 %2 找到消息号为 0x%1 的消息文本。')
>>> 

 

根据这个错误提示,回想一下自己的操作方式,在xlwings打开excel后,我按 win+d 组合键进入最小化操作,此时就报这错,如果不最小化就不报错,跟那错误的提示有些稳合。

 

但不管怎么样这都是个问题,反正已经知道问题生产的原因后续不要这么 操作即可避免该问题,但同时还是给xlwings开发人员提个单吧,看是否可以改进

单号:pywintypes.com_error: (-2147352567, '发生意外。', (0, None, None, None, 0, -2146827284), None) · Issue #1472 · xlwings/xlwings (github.com)

 

posted @ 2020-12-01 14:03  iSZ  阅读(13080)  评论(0编辑  收藏  举报