我是靠谱客的博主 高兴汽车,这篇文章主要介绍openpyxl写入百万级数据(替代xlwt row index was 65536, not allowed by),现在分享给大家,希望可以做个参考。

ValueError: row index was 65536, not allowed by .xls format
#因为xlwt不支持大数据插入 所以用openpyxl 支持一百万的数据

下面展示一些 内联代码片

复制代码
1
2
3
4
输入文件名,sheet名称,Excel的标题list 和内容的list 再次写入数据只能替换原Excel的内容
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def WriteInExcel2(dest_filename,ws1sheetname,ws1title,ws1content): wb = Workbook() dest_filename = dest_filename ws1 = wb.active ws1.title = ws1sheetname ws1['A4'] = '010174' # 写单元格 ws1.cell(row=65536, column=1).value = '01017465536' ws1.cell(row=995536, column=1, value='995536test') ws1.column_dimensions['A'].width = 20.0 #设置列的列宽 # ws1.column_dimensions['B'].width = 20.0 # 写入标题 for col in range(len(ws1title)): ws1.cell(row=1, column=col + 1).value = ws1title[col] pass for i in range(len(ws1content)): for j in range(len(ws1content[i])): ws1.cell(row=i + 2, column=j + 1).value = ws1content[i][j] #print(ws1.column_dimensions) wb.save(filename=dest_filename)

最后

以上就是高兴汽车最近收集整理的关于openpyxl写入百万级数据(替代xlwt row index was 65536, not allowed by)的全部内容,更多相关openpyxl写入百万级数据(替代xlwt内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(68)

评论列表共有 0 条评论

立即
投稿
返回
顶部