Skip to content

#2479 - Fix header/footer section parsing when &L is not first - #2482

Merged
JanKallman merged 2 commits into
develop8from
bug/i2479
Aug 26, 2026
Merged

#2479 - Fix header/footer section parsing when &L is not first#2482
JanKallman merged 2 commits into
develop8from
bug/i2479

Conversation

@swmal

@swmal swmal commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

See #2479

Problem

Header/footer sections were lost when not stored in Left, Center, Right order.

ExcelHeaderFooterText's constructor took the first section code from the first two
characters, then scanned for further codes — but only recognized &C and &R, never
&L. A &L appearing anywhere other than position 0 was not treated as a new section.
Its content was swallowed by the preceding section, then discarded when that section was
normalized, taking any &G picture placeholder with it. The picture survived in the VML
collection, so Pictures.Count was unchanged, but nothing referenced it and it stopped
rendering.

Excel writes sections in creation order, so ordinary Excel-authored files were affected.

Fix

Three changes in the constructor's parse loop:

  • &L added as a section delimiter (the actual bug)
  • pos = startPos - 1 — the loop's pos++ previously skipped a character, missing a code following an empty section
  • bound text.Length - 1 — a code in the final two characters was never seen

Tests

HeaderFooterSectionOrderTests covers ordering permutations and both boundary cases

@swmal swmal self-assigned this Aug 25, 2026
@swmal swmal added the bug Something isn't working label Aug 25, 2026
@JanKallman
JanKallman merged commit 75cc342 into develop8 Aug 26, 2026
3 checks passed
@JanKallman
JanKallman deleted the bug/i2479 branch August 26, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants