-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writer\Xlsx() produce broken files #4200
Comments
Confirmed. This looks like it's going to be a bear of a problem to solve. Excel's diagnostic messages are usually devoid of any useful information, and this case is no exception. It says it has detected invalid Xml, which is not true (otherwise LibreOffice would also not be able to read the file). The output spreadsheet has many files, and I am so far unable to devise a plan for figuring out just what is causing the problem. Workaround 1 - you can open the output spreadsheet in LibreOffice and save it to a different spreadsheet in Xlsx format. Excel can open that file. Workaround 2 - you can remove all the notes (comments) from the spreadsheet before making your copy. Excel can read the result. This could indicate that there is something wrong with the comment files, but that's not a guarantee. I don't see anything wrong with any of them. Furthermore, if I take the readable spreadsheet and add any note to it and try to load/save that file, the result is again corrupt. I don't see this problem with other files with comments - something is "special" about yours. Workaround 3 - you can save the file as Ods. You can open this file successfully in Libre Office. Excel complains when you try to open it in Excel, but, if you let it make its "corrections", it seems okay. Incomplete workarounds - you can write the file as Xls, and it is readable, but the comments are gone (no support in PhpSpreadsheet for writing comments to Xls - open item in issue #3403). |
This seems to be the same issue as the one reported in #4145 - I’m almost certain the bug was introduced by something in 1.29. |
@agaluf Thank you - that was a very valuable clue! It appears that, in the worksheet xml, the |
@oleibman , i was able to reduce it to an excel file with two cells, When opening, the excel show this error: In excel file, we have at this position Hope it helps, I don't know the Xlsx specs, and if the "ignoredErrors" is a right tag. |
@oleibman , thanks for hint with *Drawing and ignoredErrors precedence! Seems the write order fix the issue: I tested it with my template, and it goes fine! Waiting for an official fix... |
@madorin Thank you for the additional sample. It has the same problem as the others, and will be fixed soon. |
Fix PHPOffice#4200. Fix PHPOffice#4145. Although the Xml is valid, Excel insists that worksheet.xml specifies `ignoredErrors` (introduced with 1.29.0) before `legacyDrawing` or `drawing`.
This is:
I have an xlsx excel file template, open it, fill some cells and using Writer\Xlsx to save the output
Used template: template.xlsx
Generated broken output: output.xlsx
What is the expected behavior?
To generate an excel compatible file.
What is the current behavior?
It produces a broken file. However, LibreOffice opens it fine.
Xls writer, (without "x" at the end) works fine.
What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.
What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
XLSX Writer is affected, XLS writer works fine.
Which versions of PhpSpreadsheet and PHP are affected?
v3.3, v2.3
In earlier v1.x versions it worked fine. Not sure when it was broken.
The text was updated successfully, but these errors were encountered: