openpyxl icon indicating copy to clipboard operation
openpyxl copied to clipboard

Problem with image handling

Open Jackessequadro opened this issue 1 year ago • 2 comments

After re-insert the same image in the excel file and tried to reopen it the file went corrupted. In other words, when an image is updated in the excel file I can't open it anymore. I switched from version 3.1.1 to version 2.5.12 to resolve this bug. Attached you can find the error:

Traceback (most recent call last):   File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main     return _run_code(code, main_globals, None,   File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in run_code     exec(code, run_globals)   File "C:\Work\sysengpy\trunk\sysengpy_env\Scripts\tester.exe_main.py", line 7, in   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\latote\att\cmd_line.py", line 61, in tester     tester_sync_test_plan(cfg_file, path, file, var)   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\latote\att\cmd_line.py", line 112, in tester_sync_test_plan     exrep.udpate_test_case_sheets()   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\latote\att\excel_report.py", line 163, in udpate_test_case_sheets     savewb(self._wb, self.f_excel_plan)   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\latote\att\basic_report.py", line 81, in savewb     wb.save(filename)   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\openpyxl\workbook\workbook.py", line 386, in save     save_workbook(self, filename)   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\openpyxl\writer\excel.py", line 304, in save_workbook     writer.save()   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\openpyxl\writer\excel.py", line 286, in save     self.write_data()   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\openpyxl\writer\excel.py", line 88, in write_data     self._write_images()   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\openpyxl\writer\excel.py", line 127, in _write_images     self._archive.writestr(img.path[1:], img._data())   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\openpyxl\drawing\image.py", line 48, in _data     img = _import_image(self.ref)   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\openpyxl\drawing\image.py", line 16, in _import_image     img = PILImage.open(img)   File "C:\Work\sysengpy\trunk\sysengpy_env\lib\site-packages\PIL\Image.py", line 2979, in open     fp.seek(0) ValueError: I/O operation on closed file.

Thanks

Jackessequadro avatar Mar 16 '23 07:03 Jackessequadro