1
我使用pywin32和写入范围,通过获取一定范围内的物体,然后用Pywin32 Excel写入限制?
range.Value=my_data
写该青出于蓝而常见的方式(这是完全一样的语法VBA)
现在,如果我有一组相当大的单元格(> 6000个字符),并且通过设置范围对象的值一次性写出它们,那么它有时会在这些单元格之一抛出异常(但是单独写入单元格会工作)。
您是否知道我应该考虑的Excel的任何限制和写入范围操作?
例外的样子
Traceback (most recent call last):
File "test2.py", line 9, in <module>
e.write_area([tuple("a"*10000 for i in range(20))]*20, sheet="Tabelle1")
File "excel_com.py", line 209, in write_area
self.get_range(col, row, col+num_col-1, row+num_row-1, sheet=sheet).Value=data
File "C:\Python31\lib\site-packages\win32com\client\dynamic.py", line 550, in __setattr__
self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value)
pywintypes.com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, None, None, None, 0, -2146827284), None)
or
Traceback (most recent call last):
File "test2.py", line 9, in <module>
e.write_area([tuple("a"*1000 for i in range(20))]*10000, sheet="Tabelle1")
File "excel_com.py", line 209, in write_area
self.get_range(col, row, col+num_col-1, row+num_row-1, sheet=sheet).Value=data
File "C:\Python31\lib\site-packages\win32com\client\dynamic.py", line 521, in __setattr__
debug_attr_print("SetAttr called for %s.%s=%s on DispatchContainer" % (self._username_, attr, repr(value)))
MemoryError
其中excel_com.py是我的一个模块。这些例外情况是否取决于所写入数据的列,行,单元大小。不过我不知道这个系统背后的系统是什么:(
什么异常?显示** FULL **回溯和错误消息。 – 2011-05-30 01:35:42