ValueError:行索引为65536,.xls格式不允许 [英] ValueError: row index was 65536, not allowed by .xls format

查看:346
本文介绍了ValueError:行索引为65536,.xls格式不允许的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在尝试使用xlwt编辑现有的excel文件.我不想直接在excel上进行编辑,因此我首先进行复制.

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)

从此副本中,我使用xlwt模块将新列写入到新复制的excel文件中并保存.但是,尝试复制时出现错误:

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

我有点困惑,因为我复制的文件是xlsx文件,而不是xls.我从未在代码中使用xls格式.

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.

推荐答案

尝试尝试 openpyxl 代替.它支持.xlsx文件.

Try openpyxl instead. It support .xlsx files.

.xls文件的行限制为65,536. xlsutils可能不支持.xlsx文件.

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')

这篇关于ValueError:行索引为65536,.xls格式不允许的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆