2013-07-26 21 views
11

Ho ricevuto l'errore qui sotto quando eseguo lo strumento python per creare un file xls leggendo un file xml. Come lo aggiusto?xlwt che limita il numero di righe

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) 

risposta

8

Il numero massimo di righe nel file .xls è 65536. Utilizzare .xlsx preferibilmente o un altro formato che permette più righe.

4

Ho avuto lo stesso problema. Puoi provare con openpyxl anziché xlwt. In bocca al lupo!

7

È un po 'ingiusto dire che xlwt sta limitando questo. Il limite è imposto da Excel nel formato XLS.

È possibile utilizzare XlsxWriter invece che supporta i nuovi limiti XLSX di Excel di 1.048.576 righe per 16.384 colonne.

Problemi correlati