-
Notifications
You must be signed in to change notification settings - Fork 76
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
saveWorbook() creates "corrupted" excel file when autoFilter is used #127
Comments
I just compared the input and output xml files and there are missing end-tags at the end of the XML:
|
Thanks for reopening this issue under this repository and finding the root cause. |
Look like it happens (missing end tags) anytime there are additional tags added to the autofilter - not just the sort. Another case I just came across: "<autoFilter ref="A1:IZ2096"><filterColumn colId="0"><filter val="202065"/>" |
Since I was under the impression that this should I have added a Even though it works, it is merely a hack. IMHO the correct fix should happen when the |
I'm not sure if multiple autofilters are possible. If this is possible, further tweaking might be required, e.g. splitting and inserting before a second |
I assume that the issue is here: openxlsx/src/load_workbook.cpp Lines 900 to 908 in 7cb0ac8
|
Thanks @JanMarvin for the update. I am not an expert in C++ or Excel but I tried to understand a bit more the logic behind 2 different functions are used to parse XML elements:
Depending on the element name, one of this function is used. openxlsx/src/load_workbook.cpp Lines 220 to 222 in 7cb0ac8
Which is OK if autoFilter is applied with no sorting or filtering:
But not anymore if we sort or filter:
I don't know if other elements in the xml files can sometimes use empty-element-tag and sometimes start-tag and end-tag |
I didn't see you were already working on the issue: #130 😃 |
hehe, the linking did not work as expected :) |
Same bug as:
awalker89/openxlsx#524
Describe the bug
If autoFilter is use inside an Excel file, saveWorkbook() will create a "corrupted" file.
To Reproduce
Use
loadWorkbook()
on this file:auto_filter_errors.xlsx
Save the workbook using
saveWorkbook()
Open the created file with Excel
Excel gives the following error:
We found a problem with some content in ’filter_output.xlsx’. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.
Looking at the logs:
<removedParts summary="Following is a list of removed parts:"><removedPart>Replaced Part: /xl/worksheets/sheet1.xml part with XML error. Xml parsing error Line 1, column 1518.</removedPart>
Desktop :
The text was updated successfully, but these errors were encountered: