Home » excel » python – Data not present in excel sheet

python – Data not present in excel sheet

Posted by: admin April 23, 2020 Leave a comment


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

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


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

How to&Answers:

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.

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