'Issue while opening .xlsm file using openpyxl
I am currently using openpyxl to add new sheet into .xlsm file, with (read_only=False)
eg.
wb = openpyxl.load_workbook("Input_file.xlsm", read_only=False, keep_vba=True)
sheet = wb.create_sheet('Source_Data')
final_row = dataframe_to_rows(final_df)
# code to add final row to sheet Source_Data
wb.save("Input_file.xlsm")
wb.close()
Below is the error message
~\AppData\Local\Programs\Python\Python39\lib\zipfile.py in getinfo(self, name)
1427 info = self.NameToInfo.get(name)
1428 if info is None:
-> 1429 raise KeyError(
1430 'There is no item named %r in the archive' % name)
1431
KeyError: "There is no item named 'xl/drawings/NULL' in the archive"
Solution 1:[1]
I had the exact same problem. I managed to solve it easily (I don't understand exactly why but it worked). Apparently there were some images pasted in some sheets that were HIDDEN.
you need to find and delete them. (maybe making them visible will do the trick as well - I didn't check) There are two ways to so. Select each sheet in your workbook. Then:
option1: press F5 -> special -> Objects This will highlight all hidden images on sheet
option2: goto "home" tab -> press "Find & Select" -> press "Selection Pane" You can see all hidden images - and delete them
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hazkel |
