Skip to content

XLSX: keep the sensitivity label, table column data formats and sheet custom properties on save - #867

Open
marcoarnulfo wants to merge 3 commits into
storytold:mainfrom
marcoarnulfo:fix/xlsx-label-table-col-custom-props
Open

marcoarnulfo wants to merge 3 commits into
storytold:mainfrom
marcoarnulfo:fix/xlsx-label-table-col-custom-props

Conversation

@marcoarnulfo

Copy link
Copy Markdown
Contributor

Fixes #865.

None of the three were in the #330 pass-through or the model, so a plain open and save dropped them. The sensitivity label is a package-root part (classificationlabels relationship to docMetadata/LabelInfo.xml), so it now goes through the same path as custom document properties. Sheet <customProperties> and their customPropertyN.bin parts are kept like printer settings and controls, and written after <colBreaks> where the schema puts them; unlike controls they don't need the VML drawing. dataDxfId and dataCellStyle are now read into TableColumn (the dxf as a style, like conditional formats) and written back. The cell style name is only written when that named style is still in the workbook, so a deleted style can't leave a dangling reference (happy to switch to always writing it).

The form-control button anchor in the drawing part (the fourth row in the issue) isn't touched here: the drawing is rewritten by GridCraft, and the button's VML and ctrlProp were already kept.

This touches the same pass-through code as #863 (XML maps); whichever lands second will need a small rebase, which I'll do.

Validation:

  • passthrough_tests::sensitivity_label_and_sheet_custom_properties_survive_save: fails on main (no classificationlabels relationship in the output), passes here
  • fixtures::table_column_data_formats_survive_save: fails on main (dataCellStyle missing on the column), passes here
  • cargo test -p gridcraft-xlsx --lib -- tests::passthrough_tests tests::fixtures tests::roundtrip tests::array_export tests::pivot_tests
  • cargo clippy -p gridcraft-xlsx -p gridcraft-model -p gridcraft-engine -p gridcraft-calc --all-targets -- -D warnings, cargo fmt --all -- --check
  • (macOS, Apple silicon)

@richard1912

Copy link
Copy Markdown
Contributor

Thanks @marcoarnulfo, this fully fixes #865 on Windows. I tested it with the same real-world .xlsm the issue came from (15 sheets, 131 tables, macros, form-control buttons). I edited one cell, saved with this branch and opened the result in Excel 365.

#865 item Result
Sensitivity label (docMetadata/LabelInfo.xml) Kept
dataDxfId / dataCellStyle on table columns Kept
Sheet custom properties (15 customPropertyN.bin parts) All kept
Form-control buttons All 3 kept, each still anchored to the same cell
Opens in Excel Yes, no repair prompt

Also checked: all 131 tables and the VBA project survive.

While testing I found one more thing that #865 didn't cover: styling set on the <table> element itself (headerRowDxfId, dataDxfId, tableBorderDxfId, headerRowCellStyle and similar) is still dropped, just as on main. That's a separate gap, so I've filed it as #1209 and it shouldn't hold this PR up.

@marcoarnulfo

Copy link
Copy Markdown
Contributor Author

Thanks a lot for running it on the real file, that's way better than any fixture I had 🙌 Good catch on the <table>-level attributes too. Are you planning to take #1209 yourself? If not, I'm happy to pick it up once this lands, since it's the same round-trip code.

@richard1912

Copy link
Copy Markdown
Contributor

Thanks @marcoarnulfo, please go ahead with #1209, it makes sense alongside #867. Happy to test it on the same workbook when it's ready.

@marcoarnulfo

Copy link
Copy Markdown
Contributor Author

Great, on it! I'll bring this branch up to date with main first (it's conflicting now), then open #1209 on top of it. I'll ping you when it's ready to test.

This branch has not been deployed

No deployments
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.

XLSX: saving silently drops the sensitivity label (LabelInfo.xml), table column formats and sheet custom properties

2 participants