Skip to content

Headers and footers: first-page and even-page variants, Insert › Header & Footer edits in place (#344) - #404

Merged
h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
vangel76:fix/header-footer-variants
Oct 11, 2026
Merged

h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
vangel76:fix/header-footer-variants

Conversation

@vangel76

Copy link
Copy Markdown
Contributor

Fixes #344

Root cause

  • The Header & Footer button under Insert opened a dialog where you type codes (&L…&C…&R). That is easy to miss and isn't how Excel works. In-place editing in Page Layout view only arrived with View: Page Layout view with rulers and in-place headers and footers (#329) #334 (after 0.5.0).
  • XLSX import read only oddHeader/oddFooter. Many workbooks put their header on a different first page (differentFirst + firstHeader) or on even pages (differentOddEven + evenHeader). Those headers didn't show in Page Layout view or in the PDF, and saving dropped them.
  • Page Break Preview has no headers or footers in Excel either, so nothing changes there.

What changed

  • Model PrintSettings: first_header/first_footer, even_header/even_footer, different_first, different_odd_even, plus the scaleWithDoc/alignWithMargins flags (serde defaults, so older JSON still loads). HfPage picks which pair a page uses.
  • XLSX: reads and writes all six header/footer strings and the four attributes, in CT_HeaderFooter element order. Strings are capped at 255 characters on read.
  • PDF / print: the sheet's first page, even pages and the rest each print their own pair.
  • Page Layout view: each page shows its own pair. Clicking edits that pair. The header and footer presets write to it. The Header & Footer tab has Different First Page and Different Odd & Even Pages check boxes.
  • pageLayout.headerFooter accepts differentFirst, differentOddEven, firstHeader, firstFooter, evenHeader and evenFooter, plus page: odd|even|first for one-section edits, and returns them.
  • Insert › Header & Footer switches to Page Layout view and edits the first page's centre header in place, as in Excel.
  • The new strings are in all 8 catalogs.

Tests

  • engine: first_and_even_pages_print_their_own_headers
  • xlsx: the round-trip sample now sets every variant (roundtrip tests)
  • ui-egui tests/page_layout_view.rs: the_first_page_edits_its_own_header_when_different_first_page_is_on, insert_header_and_footer_switches_to_page_layout_view
  • Commands run: cargo test -p gridcraft-engine --lib -- first_and_even header every_command, cargo test -p gridcraft-xlsx roundtrip, cargo test -p gridcraft-ui-egui --test page_layout_view, cargo test -p gridcraft-ui-egui --lib i18n, clippy -D warnings on model/xlsx/engine/ui-egui (lib, that test, snapshot example), cargo fmt --check. The offscreen snapshot of an edit with Different First Page was checked.

Not done

  • Header/footer pictures (&G) and Excel's Scale with Document / Align with Page Margins behaviour. The flags are kept, but layout ignores them.
  • The Page Setup dialog has no Header/Footer tab. The headerFooter codes dialog is no longer on the ribbon; the command stays available.

Unverified

  • With "Print Entire Workbook", odd/even uses the printed page number (&P), and "first page" means each sheet's first page. I believe this matches Excel, but I haven't checked it there.

🤖 Generated with Claude Code

…er & Footer edits in place (storytold#344)

XLSX headerFooter kept only oddHeader/oddFooter: a workbook whose header is on a
different first page (differentFirst + firstHeader) or on even pages showed no
header, and saving dropped it. The model now keeps the first/even headers and
footers and the differentFirst / differentOddEven / scaleWithDoc / alignWithMargins
flags; XLSX reads and writes them; the PDF and the Page Layout view use the right
pair per page; in-place editing edits the page's own pair, and the Header & Footer
tab has Different First Page and Different Odd & Even Pages. pageLayout.headerFooter
takes the variants and a page: odd|even|first for one-section edits.

Insert › Header & Footer now switches to Page Layout view and edits the first
page's centre header, as in Excel, instead of opening the codes dialog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 4a23b9c into storytold:main Oct 11, 2026
@echelon

echelon commented Oct 11, 2026

Copy link
Copy Markdown
Member

Merged — thank you for the contribution!

If you haven't already, come join us on the ArtCraft Discord: https://discord.gg/artcraft

dabaicai001 added a commit to dabaicai001/gridcraft that referenced this pull request Oct 16, 2026
storytold#404's header/footer variants landed after storytold#413's French table, leaving the
translation-completeness test red.
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.

Header Footer

3 participants