Fix formula text truncated on XML character references - #348
Conversation
quick-xml emits numeric character references (e.g. –) as GeneralRef events between Text fragments. DataValidation and Formula parsers replaced the accumulator on each Text event and ignored GeneralRef, so list formulas were truncated to the last fragment. Append Text and GeneralRef instead, with unit coverage for en-dash list formulas. Also close a missing brace in number_formater tests that broke compilation.
|
@sentinelt There are a few other instances of this, so it looks like we’ll need to review the entire code. |
|
Thank you. I can confirm this fixed my problem. Sorry I never got time to work on it. Been under pressure. PS. The hash of the output xlsx file has changed but I wasn't able to easily find the difference. It still has the some contents when saved as csv. I recall there was a tool you used to compare the files but I can't recall what it was and can't remember in which pr or issue you'd spoken about it. Would you mind sharing the tool again so I can look into what changed in the file please. |
|
@c-git I’m currently using this VSCode extension to check XML. (There used to be a very user-friendly Google Chrome extension, but it’s now deprecated and can no longer be used.) |
Thank you very much |

Summary
dataValidation/ formula character data that contains XML numeric character references (e.g.–for an en-dash) was truncated when reading.xlsxfiles.Root cause
quick-xml emits those references as
Event::GeneralRefnodes between successiveEvent::Textfragments. The parsers forDataValidation(formula1/formula2) andFormulareplaced the accumulator on eachTextevent and ignoredGeneralRef, so only the last text fragment survived.Example list formula in a real workbook:
was read as:
instead of the full list string.
Fix
Textevents instead of overwritingGeneralRef(numeric char refs + common named entities)append_xml_text/append_xml_general_refnumber_formatertests that broke compilation of the local tree