Skip to content

XLSX: keep header and footer pictures on save - #1600

Merged
aiongg merged 1 commit into
storytold:mainfrom
marcoarnulfo:fix/xlsx-keep-header-footer-pictures
Oct 22, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
marcoarnulfo:fix/xlsx-keep-header-footer-pictures

Conversation

@marcoarnulfo

Copy link
Copy Markdown
Contributor

Part of #1257.

Excel stores header and footer pictures (&G in the header text) in a VML drawing of their own, which the sheet names with <legacyDrawingHF>, plus the images that drawing points at. The XLSX pass-through (#333) only looked for <legacyDrawing>, so on save the &G codes stayed in the header text but the element, the VML part and the images were dropped, and the letterhead was gone the next time the file was opened in Excel. This keeps that drawing and its images byte for byte with the rest of the sheet's kept content, and writes <legacyDrawingHF> back in schema order right after <legacyDrawing>. A sheet with a note and a header picture keeps both drawings separate, and the notes drawing GridCraft writes now takes VML shape blocks after the ones the kept header drawings use, so the two can't end up with the same o:idmap block and shape ids.

What's left of #1257: GridCraft still doesn't show header/footer pictures in print preview or Page Layout, and can't insert new ones. That's a bigger piece (rendering plus an Insert Picture flow in the header editor), so this PR only stops them from being lost on save. Opening such a file adds a "not shown; kept for saving" note like the one for embedded objects, happy to drop it if it's too noisy.

Validation:

  • passthrough_tests::header_and_footer_pictures_survive_a_save (header logo + footer picture + a note, saved twice): fails on main (no <legacyDrawingHF> in the saved sheet), passes here
  • passthrough_tests::notes_take_shape_blocks_the_header_pictures_dont_use: on the first fix alone the notes reused block 1 (notes reuse shape block 1), passes here
  • cargo test -p gridcraft-xlsx --lib -- passthrough roundtrip malformed, cargo clippy -p gridcraft-xlsx --all-targets -- -D warnings, cargo fmt --all -- --check
  • docs/file-format-parity.md updated
  • (macOS, Apple silicon)

jesusthehelper-oss added a commit to jesusthehelper-oss/gridcraft that referenced this pull request Oct 19, 2026
# Conflicts:
#	docs/file-format-parity.md
@aiongg
aiongg merged commit faef39c into storytold:main Oct 22, 2026
1 check passed
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.

2 participants