Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xlwt limiting the number of rows

I got the error below when I run the python tool to create an xls file by reading an xml file. How do I fix it?

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)
like image 248
user2190483 Avatar asked Jul 26 '13 11:07

user2190483


3 Answers

The maximum number of rows in .xls file is 65536. Use .xlsx instead or another format that allows more rows.

like image 179
matino Avatar answered Nov 03 '22 09:11

matino


It is a bit unfair to say that xlwt is limiting this. The limit is imposed by Excel in the XLS format.

You could use XlsxWriter instead which supports the new Excel XLSX limits of 1,048,576 rows by 16,384 columns.

like image 20
jmcnamara Avatar answered Nov 03 '22 10:11

jmcnamara


I had the same problem. You can try with openpyxl instead of xlwt. Good luck!

like image 4
toscanelli Avatar answered Nov 03 '22 08:11

toscanelli