xlwt限制行数

use*_*483 11 python xlwt python-2.7

当我运行python工具通过读取xml文件创建xls文件时,我得到了以下错误.我如何解决它?

ValueError: row index (65536) not an int in range(65536)
File "D:\Zipfiles\Script_try.py", line 82, in _execute_test
    self.parser = parser()
  File "D:\Zipfiles\Script_try.py", line 216, in __init__
    self._xml_parser()
  File "D:\Zipfiles\Script_try.py", line 306, in _xml_parser
    sheet1.write(row,1,[test_x.attrib['name']],centr)
  File "C:\Python26\lib\site-packages\xlwt\Worksheet.py", line 1030, in write
    self.row(r).write(c, label, style)
  File "C:\Python26\lib\site-packages\xlwt\Worksheet.py", line 1078, in row
    self.__rows[indx] = self.Row(indx, self)
  File "C:\Python26\lib\site-packages\xlwt\Row.py", line 42, in __init__
    raise ValueError("row index (%r) not an int in range(65536)" % rowx)
ValueError: row index (65536) not an int in range(65536)
Run Code Online (Sandbox Code Playgroud)

mat*_*ino 9

.xls文件中的最大行数为65536.使用.xlsx或其他允许更多行的格式.


jmc*_*ara 9

说xlwt限制了这一点有点不公平.Excel以XLS格式强制限制.

您可以使用XlsxWriter,它支持新的Excel XLSX限制1,048,576行16,384列.