MathNya / umya-spreadsheet

A pure rust library for reading and writing spreadsheet files
MIT License
238 stars 41 forks source link

Saving spreadsheet with images result in errors - does not round-trip #188

Open schungx opened 1 month ago

schungx commented 1 month ago

Read a spreadsheet file with embedded images, then writing it back out as a new file.

The new file contains errors (Excel pops up warnings). Images are missing.

Attached is the test file test.xlsx and the output file output.xlsx.

MathNya commented 1 month ago

@schungx Thank you for your report. We will investigate the cause.

schungx commented 1 month ago

Anything I can do to help diagnose this problem? It seems to only happen when there are embedded images.

Most images ended up disappearing, but some are intact.

MathNya commented 1 month ago

@schungx Thank you very much. By analyzing the file you submitted, we were able to determine the cause of the error. We have corrected the program. Please obtain the latest version and check it.

schungx commented 1 month ago

Will do and revert.

schungx commented 1 month ago

I confirm that your fix solved the problems with the test file.

However, with a real file with hundreds of images, it comes back with errors:

image

with the log:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog
    xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
    <logFileName>error545240_01.xml</logFileName>
    <summary>Errors were detected in file 'C:\Git\holycrown\xyz.xlsx'</summary>
    <repairedRecords>
        <repairedRecord>Repaired Records: Drawing from /xl/drawings/drawing1.xml part (Drawing shape)</repairedRecord>
        <repairedRecord>Repaired Records: Drawing from /xl/drawings/drawing2.xml part (Drawing shape)</repairedRecord>
    </repairedRecords>
</recoveryLog>

The most annoying thing is... it sometimes swap images with some other images, but not all the time.

I'll try to make another test file for you.

schungx commented 1 month ago

Here is another test file with the output. You'll find that:

1) There are errors when opening output.xlsx saying that some drawings have been fixed

2) Many images are swapped to something entirely different

3) Some images are not found

test2.xlsx

output.xlsx

MathNya commented 1 month ago

@schungx Hmmm, looks like it needs a little more renovation. We will continue to address this issue.