Excel file becomes corrupted when saved
Created originally on Bitbucket by Per
Hello,
I have an Excel file (“openpyxl_corrupt_file.xlsx”) which becomes corrupted when saved (“openpyxl_corrupt_file_saved.xlsx”) as seen in the attached screen dump (“Capture.JPG”). The screen dump is generated when the saved filed is opened and repaired in Excel.
The saved file is generated by (See the attached script “openpyxl_corrupt_file.py” ):
import openpyxl
wb = openpyxl.load_workbook(filename=r'C:\temp\openpyxl_corrupt_file.xlsx', data_only=True)
wb.save(filename=r'C:\temp\openpyxl_corrupt_file_saved.xlsx')
I hope you are able to figure out how to modify the openpyxl code to ensure it writes a correct Excel file.
Openpyxl version = 2.6.2
PS: If the “custom view” is removed from the excel file then the file seems to be correctly saved.
PPS: I’m a newbie and this is my first issue report, so if you have any advise/suggestions to improve my description or anything else don’t hesitate to let me know
Thanks in advance and thanks for a great module
Attachments: Captureopenpyxl_corrupt_file.pyopenpyxl_corrupt_file.xlsxopenpyxl_corrupt_file_saved.xlsx