ValueError: row index was 65536, not allowed by .xls format

十年热恋 提交于 2020-02-02 06:22:25

问题


Currently, I am trying to edit an existing excel file using xlwt. I do not want to edit directly on the excel, so I first make a copy.

new_wb = xlutils.copy(file_location)

From this copy, I used the xlwt module to write a new column into the newly copied excel file and save. However, I get an error when I try to copy:

ValueError: row index was 65536, not allowed by .xls format

I am a little confused because the file I duplicate is a xlsx file, not xls. I never use the xls format in my code.

Any guidance would be greatly appreciated.


回答1:


Try openpyxl instead. It support .xlsx files.

The row limit of .xls files is 65,536. xlsutils might not be supporting .xlsx files.

You can try doing this to see if it works:

from openpyxl import Workbook, load_workbook

wb = load_workbook('filename.xlsx')
wb = Workbook(write_only=True)
.
.
.
(make your edits)
.
.
.
wb.save('new_filename.xlsx')


来源:https://stackoverflow.com/questions/45741670/valueerror-row-index-was-65536-not-allowed-by-xls-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!