Skip to content

Fix formula text truncated on XML character references#348

Open
sentinelt wants to merge 1 commit into
MathNya:masterfrom
sentinelt:fix/data-validation-formula-char-refs
Open

Fix formula text truncated on XML character references#348
sentinelt wants to merge 1 commit into
MathNya:masterfrom
sentinelt:fix/data-validation-formula-char-refs

Conversation

@sentinelt

@sentinelt sentinelt commented Jul 22, 2026

Copy link
Copy Markdown

Summary

dataValidation / formula character data that contains XML numeric character references (e.g. – for an en-dash) was truncated when reading .xlsx files.

Root cause

quick-xml emits those references as Event::GeneralRef nodes between successive Event::Text fragments. The parsers for DataValidation (formula1 / formula2) and Formula replaced the accumulator on each Text event and ignored GeneralRef, so only the last text fragment survived.

Example list formula in a real workbook:

<formula1>"0&#8211;3 years ago,4&#8211;5 years ago,6&#8211;7 years ago"</formula1>

was read as:

7 years ago"

instead of the full list string.

Fix

  • Append successive Text events instead of overwriting
  • Resolve and append GeneralRef (numeric char refs + common named entities)
  • Shared helpers: append_xml_text / append_xml_general_ref
  • Unit tests covering en-dash list formulas and plain list formulas
  • Close a missing brace in number_formater tests that broke compilation of the local tree

quick-xml emits numeric character references (e.g. &#8211;) 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant