- edited description
Writing XLSX: Image is not inserted and excel complains about drawing issue on open
After switching from v2.5.9 to 2.5.10 my code for generating an excel file with a drawing added is not working any more as expected. The file created makes excel issuing a warning about a "corrupted file". Excel offers to repair the file and successfully opens it after repair but the png image imported is not visible. Looking into the xlsx files with a zip tool I found the png image is correctly placed in the excel file but in difference to 2.5.9 the file "./xl/drawings/drawing1.xml" is not filled correctly as with 2.5.9. Please see the attached files generated with 2.5.9 and 2.5.10 version.
I just verified the odd behaviour with 2.5.11 too.
The following code snippet shows how I am adding the image.
img = Image(logofile) self.wb.active.add_image(img,addr)
Comments (7)
-
-
Thanks for the report and the sample files. 2.5.10 does contain a slight change on the way anchors are handled for better processing of some existing files but it shouldn't have changed existing behaviour.
-
- changed status to resolved
Must bind the picture frame to the anchor when adding a new image. Resolves
#1133but test required.→ <<cset 3977977a46e6>>
-
I inserted the new code in 2.5.11 and it worked.
Excellent, thank you!
EDIT: Bug is fixed in 2.5.12
-
Issue
#1137was marked as a duplicate of this issue. -
I'm getting this problem with 2.5.11. I'm running the sample code:
wb = Workbook() ws = wb.active ws['A1'] = 'You should see three logos below' # create an image img = Image('logo.png') # add to worksheet and anchor next to cells ws.add_image(img, 'A1') wb.save('logo.xlsx')
The Excel recovery report isn't very helpful:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error119160_05.xml</logFileName><summary>Errors were detected in file 'C:\code\StatsReporter\stats_reporter\logo.xlsx'</summary><repairedRecords><repairedRecord>Repaired Records: Drawing from /xl/drawings/drawing1.xml part (Drawing shape)</repairedRecord></repairedRecords></recoveryLog>
-
@timk you'll actually need to 2.5.12 for this. Always worth checking the release notes.
- Log in to comment