Skip to content

Fix prefixed worksheet content in the compatibility reader - #14

Merged
developer0hye merged 1 commit into
fix/panic-safety-v2from
fix/worksheet-namespace-fork
Sep 20, 2026
Merged

developer0hye merged 1 commit into
fix/panic-safety-v2from
fix/worksheet-namespace-fork

Conversation

@developer0hye

Copy link
Copy Markdown
Owner

Summary

Port the worksheet namespace-resolution fix from MathNya#371 to the 2.3.3 compatibility branch used by office2pdf. Prefixed SpreadsheetML cells and header/footer content currently disappear during normal and lite/lazy reads.

The bounded event adapter resolves element namespaces before the existing worksheet sub-readers dispatch on their names. It preserves source XML, nested namespace scope, entities and CDATA, and keeps foreign-default-namespace local names out of the worksheet parser. No dependencies or public APIs change.

Related: developer0hye/office2pdf#1803, MathNya#370.

Validation

  • Red-first regression: default namespace passed; two prefixed variants produced no cells.
  • Normal/deferred reads, lite cells, formatting, headers/footers and write/reopen round trips now pass.
  • cargo test --locked: 157 passed.
  • cargo clippy --locked -- -D warnings, cargo fmt --all -- --check, and git diff --check: passed.
  • README reviewed; existing dependency ranges and usage remain valid.

The upstream optimized benchmark measured approximately 1.6% additional normal-read time and 34.1% additional callback-streaming-read time for 40,000 cells on the test host. That result is disclosed in upstream PR MathNya#371; this older fork has no equivalent callback-streaming API, so those timings are not a measurement of this branch. The extra namespace pass is an explicit performance tradeoff.

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
@developer0hye
developer0hye merged commit fa35018 into fix/panic-safety-v2 Sep 20, 2026
3 checks passed
@developer0hye
developer0hye deleted the fix/worksheet-namespace-fork branch September 20, 2026 16:41
developer0hye added a commit to developer0hye/office2pdf that referenced this pull request Sep 27, 2026
A worksheet may bind the SpreadsheetML URI to a prefix instead of making
it the default namespace. Excel writes and accepts both spellings, and
the two packages are equivalent XML: identical expanded element names,
attributes and text.

The dependency's worksheet reader matched literal `e.name()` values such
as `row` and `headerFooter`, so `s:row` and `s:headerFooter` matched
nothing. Every sheet element was skipped, the converter reported success,
and the page came out blank — body cells, header and footer all gone.

The fix is a streaming `NsReader` adapter in the dependency
(developer0hye/umya-spreadsheet#14, upstream MathNya/umya-spreadsheet#371)
that resolves each event's namespace and hands the legacy sub-readers the
unqualified local name when, and only when, the URI is SpreadsheetML.
Elements in a foreign namespace take an internal prefix so the legacy
parser cannot mistake their local names for worksheet elements. It buffers
one event, so worksheet streaming is preserved, and the stored source XML
is untouched. Only the lock's `source` line moves; the fork delta over the
previous pin is that adapter, its wiring and its tests.

The regression test pins the rule rather than the reported input: it reads
the committed `s:`-prefixed fixture and four more prefixes generated from
the default-namespace control, including `row:`, which a substring-matching
reader would still get wrong. Both the whole-document and the streaming
parse paths are checked for every body value, the header, and the footer's
three sections with their page-number fields.

The prefixed and default-namespace packages now convert to a
byte-identical PDF, and the default-namespace output is unchanged.

Related: #1803

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
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