Excel file with bubble chart-- saving causes unreadable content error

Issue #1455 resolved
Charlie Heitzig created an issue

We have a fairly complex template Excel file that we’re populating with openpyxl and then saving as another file. The process involves opening the template file each time, populating it with data, and then saving it as a (bunch of) new filenames. We’ve simplified the example down to a template with just two tabs-- one with the bubble chart on it and one with the data (although practically speaking, it could probably be all on one tab if that helps). We also have simplified the openpyxl-calling code down to a four line Python script that just opens, saves, and closes the file. After opening, saving, and closing the file, we get an error from Excel that says “Excel found unreadable content in <filename>. Do you want to recover the contents of this workbook? (etc.)” If we recover the file, it removes the bubble chart, but everything else is intact.

Tested with Python 3.7.4 and with openpyxl versions 3.0.3 and 2.6.4

Comments (6)

  1. Charlie Heitzig reporter

    Three files attached are:

    • ReallyReallySimpleTemplate.xlsx-- template file that I open and save
    • opensave.py-- four line Python script that opens the template and saves to simple_save.xlsx
    • simple_save.xlsx-- the resulting file

  2. CharlieC

    Thanks for the detailed report and the sample file. Excel is really sensitive to anything in the Excel and if there is anything in a chart it doesn’t like it will dump the whole “drawing” that contains the chart.

    I know I never tested the code that reads charts with bubble charts so it’s probably some kind of missing attribute. You can, if you know what you’re doing, try debugging this yourself by comparing the XML of the source and target files in a relevant editor or the Office OpenXML Productivitry Tool, but it’s easily to be thrown off by cached items and additional “compatability” markup that Excel includes.

  3. Charlie Heitzig reporter

    Thanks, Charlie (nice name, btw!)

    Questions on the debugging process:

    • I did a compare of the overall .xlsx file between the two files, and of the 19 files that were in the .zip (I renamed .xlsx to.zip to open), 18 were different.
    • Should I be looking at the drawing1.xml (which is the file that gets dropped when Excel repairs)?

    Also, two testing updates:

    • I tried a different kind of chart (a line chart, I think), and it worked fine.
    • And, I created a new bubble chart from scratch and can cause the error trivially

  4. CharlieC

    You just need to look at chart1.xml but diffing XML which has differing namespaces and additional, optional is **not* easy.

  5. Log in to comment