Skip to content

XLSX: keep a dxf's protection, font size and face, and the font parts it turns off - #1225

Merged
aiongg merged 1 commit into
storytold:mainfrom
marcoarnulfo:fix/xlsx-dxf-protection-font-off
Oct 22, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
marcoarnulfo:fix/xlsx-dxf-protection-font-off

Conversation

@marcoarnulfo

Copy link
Copy Markdown
Contributor

Part of #1209.

The shared dxf writer (<dxfs> in styles.xml) dropped a differential format's <protection>, leaving an empty <dxf/>, never wrote the font's sz and name, and only wrote the font parts that were turned on, so <b val="0"/>, <i val="0"/> and <u val="none"/> were lost. A header dxf that turns bold off lost it, and the table style made the header bold again.

A dxf's Style reads its default parts as unset, so "bold off" or "locked, not hidden" can't be told from "not stated". The reader now records those in a small DxfStated on Style, only where the stated value matches the default (empty for cell formats and for formats made in the app), and keeps a stated face and size in the font. The writer writes them back, along with scheme. Nothing that renders conditional formats or tables reads the new field.

Thanks @richard1912 for finding these while testing #1221 on a real workbook.

Validation:

  • fixtures::dxf_font_and_parts_stated_at_their_defaults_survive_save: four dxfs (font parts turned off, size/face/scheme at their defaults, a default protection, a non-default one, a non-default size and face), checked against the <dxfs> written on save. Fails on main (<dxfs count="2"><dxf></dxf><dxf><font><b/></font></dxf>), passes here
  • cargo test -p gridcraft-xlsx --lib -- tests::fixtures tests::roundtrip, cargo test -p gridcraft-engine --lib -- cf::
  • cargo clippy -p gridcraft-model -p gridcraft-xlsx -p gridcraft-engine -p gridcraft-ui-egui --all-targets -- -D warnings, cargo fmt --all -- --check
  • (macOS, Apple silicon)

@richard1912

Copy link
Copy Markdown
Contributor

Tested together with #1221 on the real workbook: protection, the font parts turned off and sz/name/scheme all survive save now, and rows added in Excel come out identical to the original. Details in #1221 (comment). Thanks @marcoarnulfo!

@marcoarnulfo

Copy link
Copy Markdown
Contributor Author

Awesome, thanks for running both again @richard1912, really appreciate it 🙌

aiongg added a commit to aiongg/gridcraft that referenced this pull request Oct 22, 2026
Schema order is font, numFmt, fill, alignment, border, protection.
aiongg added a commit to aiongg/gridcraft that referenced this pull request Oct 22, 2026
…and family on save

crates/xlsx/src/styles.rs: family/charset block ported into the dxf.is_none() branch of font_xml (PR storytold#1225 made it take Option<&DxfStated>)
docs/file-format-parity.md: header Change line keeps both sides' clauses
@aiongg
aiongg merged commit 522b8a1 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.

3 participants