Repository navigation
File formats: CSV/TSV export writes displayed values; templates and .xlsm saved with their own content types - #422
Merged
Conversation
…xlsm saved with their own content types Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 11, 2026
Merged
This was referenced Oct 11, 2026
Closed
Member
|
Merged — thank you for the contribution! If you haven't already, please join our Discord: https://discord.gg/artcraft |
This was referenced Oct 12, 2026
Closed
neilcawse
added a commit
to neilcawse/gridcraft
that referenced
this pull request
Oct 12, 2026
…/footer labels CSV/TSV export ran General numbers through the 11-character cell display, so a barcode like 124412140710 was saved as 1.24412E+11. display::value_text now writes a General number as & converts it (number_to_text), as its doc already said; cell_text keeps the cell display. Fixes the two storytold#426 tests that broke when storytold#422 merged. Adds the French "Different First Page" / "Different Odd & Even Pages" labels missing after storytold#413, which failed the i18n completeness test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
@text), formula results, errors and booleans as shown. It never writes column-width#####and never applies the grid's General narrowing, so the field holds the whole value. This follows Microsoft's description of Save As CSV/Text ("the text and values as they are displayed in cells", all characters kept). Before this change the export wrote raw values (46023instead of2026-01-01).engine::display::value_textis split out ofcell_text: it formats the value without the show-formulas branch. A sheet with Show Formulas on still exports values.gridcraft_xlsx::write_csv(sheet, delimiter, cell_text)takes a closure that supplies each field's text. Quoting, CRLF line ends and UTF-8 without BOM stay in the xlsx crate, and formatting stays in the engine (layering). The old rawfield_texthelper is removed..xltx,.xltmand.xlsmare saved with their ownxl/workbook.xmlcontent type (template, macro-enabled template, macro-enabled workbook). Before, every one of them got the.xlsxworkbook type, which Excel rejects for a template. The newXlsxKind::from_pathpicks the kind from the extension (case-insensitive; unknown or missing extensions give.xlsx).write_xlsx_as(wb, kind)writes it.xl/vbaProject.binonly for.xlsmand.xltm(XlsxKind::is_macro_enabled), sosave_bytesno longer clones the workbook to strip it, and a macro-enabled template keeps its macros.write_xlsx(wb)behaves as before:.xlsmwhen the workbook holds a VBA project,.xlsxotherwise. TheCT_WORKBOOK_MAIN/CT_WORKBOOK_MAIN_MACROconstants are replaced byXlsxKind::main_content_type.Tests
engine io::tests::csv_writes_displayed_text: date, currency, percent, fraction, text-format007,#N/A,TRUE, formula result, a too-narrow column (no#####), General negative, thousands. Show Formulas is on. Checks the exact CSV bytes, including quoting of"$1,234.50", and the TSV prefix.engine io::tests::template_extension_saves_template_content_type:save_bytes(.., "Budget.xltx")writes the template content type.engine io::tests::macros_are_saved_only_into_xlsmalso checks that.xltmkeeps the VBA project and.xltxdrops it.xlsx tests::roundtrip::package_kind_sets_workbook_content_type: for each of the four kinds,from_pathmaps the extension (including upper case and a dotted directory), the[Content_Types].xmloverride for/xl/workbook.xmlis correct, and the file reads back with no warnings.xlsx tests::csv_tests::writingis updated for the newwrite_csvsignature (raw-value closure), with the same expected output.Commands run:
All pass.
Docs
docs/file-format-parity.md: header Change line, the.xlsmand.xltx/.xltmrows (content type fixed, tests named; the.xlsmrow also stops saying macros are dropped, which has been wrong since VBA Macros support #6 landed), the.csvand.txtrows ("displayed values"), the Work table (CSV/textrow drops "displayed-value export", 5–8 h → 4–7 h), and a new history row.docs/parity-checklist.mdis unchanged (cargo xtask parity --checkreports it up to date).Not done
.xltmgets the VBA project only from a workbook that already had one (opened.xlsm/.xltm); there is still no macro editing.docs/file-format-parity.mdcurrently has three.xlsxrows, left over from Parity: XLSX › threaded comments and persons parts round trip #300, Parity: Review › Protect › Allow Edit Ranges (review.allowEditRanges) #307 and Parity: XLSX › keep unmodelled parts on save (pass-through) #330 landing separately. This PR leaves them alone.Unverified: needs confirmation in Excel
.xltx/.xltm/.xlsmpackages without a repair prompt. Only our reader and the content-type strings from ECMA-376 were checked.[h]:mm. These use the same formatter as the grid, which has not been compared against Excel's CSV output.