openpyxl save corrupts simple xlsx workbook with external link
Book1 and Book2 are both simple xlsx files with no charts comments or drawings. Book1 links to Book2 via a formula.
If I use openpyxl to open Book1 and save it (no changes have been attempted) then Book1 becomes corrupted.
I have tried a number of different versions of openpyxl:
- 3.0.3
- 2.4
- 3.1.1
- 3.1.2
Here is the code I use to open and save Book1
def main():
f1="C:/Temp/temp/Book1.xlsx"
print(openpyxl.__version__)
wb=openpyxl.load_workbook(filename=f1)
wb.save(f1)
wb.close()
Here is the error message I get
If I allow Excel to attempt to recover the file, the external link appears as: =[RecoveredExternalLink1]Sheet1!$B$1
I can update this link to the original file and no other corruption appears to have occurred.
I suspect this issue is linked to #1992 (closed) which is closed. I cannot be sure.