I'm reading a existing excel file by using openpyxl package and trying to save that file it, and it got saved but after opening that excel file no data is present. I used the following code and my requirement is to open the file in use_iterators = True mode only

我正在使用openpyxl包读取现有的excel文件并尝试保存该文件,并保存但是在打开excel文件后没有数据存在。我使用了以下代码,我的要求是仅在use_iterators = True模式下打开文件

from openpyxl import load_workbook
wb = load_workbook(filename = 'large_file.xlsx', use_iterators = True)

ws = wb.get_sheet_by_name(name = 'big_data') 

for row in ws.iter_rows():

    for cell in row:

        print cell.internal_value

wb.save("large_file.xlsx")

can u guys show how to save the file and close the file after saving with out losing the data

你们可以展示如何保存文件并在保存后关闭文件而不丢失数据

1 个解决方案

#1


2

Try loading with use_iterators = False, as use_iterators = True loads the data information differently, such that it may not contain all the information you wish to save.

尝试使用use_iterators = False加载,因为use_iterators = True会以不同方式加载数据信息,因此它可能不包含您要保存的所有信息。

Openpyxl writes and entirely new excel file based on the information it has read in, so it's not like you make a small change and just update the file. (This also means if certain features aren't supported in openpyxl (such as VB macros), these won't exist in the file you've saved.)

Openpyxl基于它读入的信息编写了全新的excel文件,因此它不像你做一个小改动而只是更新文件。 (这也意味着如果openpyxl中不支持某些功能(例如VB宏),这些功能将不会存在于您保存的文件中。)

更多相关文章

  1. 如何使用未受标头影响的python导入csv文件,其中第一列为非数值
  2. 套接字。接受错误24:对许多打开的文件
  3. c++与python关于二维数组的数据传递问题,刚注册没有分,以后一定补
  4. Python使用pandas对数据进行差分运算
  5. 利用Python进行数据分析-- 学习心得(汇总)
  6. Python之错误异常和文件处理
  7. python python 入门学习之网页数据爬虫cnbeta文章保存
  8. python尝试自定义数据结构不知道怎么下手
  9. python解析json文件读取Android permission说明

随机推荐

  1. HTML哪些是块级元素,哪些是行内元素、
  2. 使用Semantic-UI垂直对齐div
  3. sublime3安装liveload,实现前端自动F5刷新
  4. TP-link 无线路由器WDS设置方法图解_无线
  5. 如何在刀片服务器的foreach循环中插入表
  6. 真人演示乳房按摩法 咪咪大而不垂
  7. 如何在动态创建的HTML标签内容中避免单引
  8. HTML+CSS实现审核流程步骤效果
  9. 使用下一个div中的文本设置“下一个”按
  10. 关注“飞翔的键盘” 近期PlayBook/QNX开