Excel file becomes corrupted when saved
*Created originally on Bitbucket by [Per](https://bitbucket.org/%7B7239382e-538c-48c3-a65d-3aec57902a5e%7D/)*
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:* [Capture](/uploads/c330da5c85fd301eb386be6c7d3c4afc/Capture.JPG)[openpyxl_corrupt_file.py](/uploads/2fe83983975da238051d19e827d6838e/openpyxl_corrupt_file.py)[openpyxl_corrupt_file.xlsx](/uploads/5c6319b5b4bb754afa5eae0e1866aea9/openpyxl_corrupt_file.xlsx)[openpyxl_corrupt_file_saved.xlsx](/uploads/d2ac379531a533f244d48a871bbeff0a/openpyxl_corrupt_file_saved.xlsx)
issue