Writing XLSX: Image is not inserted and excel complains about drawing issue on open

Issue #1133 resolved
G. Wiora
created an issue

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)

Comments (7)

  1. CharlieC

    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.

  2. timk

    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')

    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>
  3. Log in to comment