Not able to read the written content in excel file - openpyxl v2.0.4

Issue #348 resolved
Shaun Thomas
created an issue


I opened and read values from an existing excel file using openpyxl (v2.0.4) with attribute use_iterators = True. Then I updated some cells with new data (using normal mode, not optimized). A snippet of the code which I used is given below.

workbook = load_workbook(excelFileName)
worksheet = workbook.get_sheet_by_name(sheetName)
worksheet['B2'] = "Some value"

Now when I open the excel file, it is full blank and the cell start location is 'AML1'. I am not able to see any cells before it. If I type the cell name in the selection field it shows the correct value. But I am not able to see it in the spreadsheet.

Ps: This writing feature works perfectly fine in v1.8.5. I notice the problem in v2.0.4 only.

Attachment: A sample excel file generated through openpyxl with the above said issue.

Comments (11)

  1. CharlieC

    You say you open a file with use_iterators=True? Such workbooks are read only and cannot be saved.

    Cells before AML1 are marked as hidden. Without the original file I cannot say why this is the case but if you are trying to modify a read only workbook I wouldn't be surprised if that is the cause.

  2. Shaun Thomas reporter

    What I have given is process description. Actually I am using 2 different python files which access the excel file using openpyxl. One is for excel reading and other is for excel writing. The code given above is from excel writing python file. That is why it doesn't have second attribute use_iterators = True in the load workbook statement.

    Cells before AML1 are made hidden by openpyxl writer only. Again I repeat that it is working fine in openpyxl v1.8.5 (I am using this version in my project now). Problem is with openpyxl v2.0.4 only.

    I don't actually remember the exact content of the excel file now. I made it just for testing purpose only with some sample data in 3 sheets. If you still want, I can create and provide an excel file which is close to the original.

  3. Shaun Thomas reporter

    As I cannot share you my project code, I try to create a sample python file and tried to replicate the issue.

    Below is the code from the python file

    from openpyxl import load_workbook
    print "Going to execute the script"
    workbook = load_workbook("EmptyCellsTest2.xlsx")
    worksheet = workbook.get_sheet_by_name("Sheet1")
    worksheet['B8'] = "Customer07""EmptyCellsTest2.xlsx")
    print "End of script execution"

    The excel file have all cells as hidden after the execution of the above excel write script. I have attached the original excel file (EmptyCellsTest2-original.xlsx) and file after writing (EmptyCellsTest2.xlsx).

  4. Log in to comment