From ecf0e3a6e5d19b0cffc9d0563c2d5038de5f23d0 Mon Sep 17 00:00:00 2001 From: Eduardo Soares Date: Mon, 12 Oct 2026 10:47:04 -0300 Subject: [PATCH 1/3] CSV: General numbers save at full precision (12-digit codes saved as 1.24412E+11) PR #422 (CSV writes displayed values) routed Save As CSV through value_text, whose General branch is the 11-character format_general_fit used for cell display: any number wider than 11 characters came out in scientific notation. Excel's Save As CSV/Text writes General values at full precision (up to 15 significant digits), as value_text's doc already promised ("no General narrowing"); the grid narrows General by the real column width itself. value_text now returns number_to_text for General numbers, so cut-list part codes like 124412140710 round-trip again (tests from #426), and formats still apply to every other number format. Merged the duplicated text-format rows in docs/file-format-parity.md (left over from the #422/#426 merges). --- crates/engine/src/display.rs | 11 ++++++++++- docs/file-format-parity.md | 7 +++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/display.rs b/crates/engine/src/display.rs index db7e7c8fbf..3ae65f7604 100644 --- a/crates/engine/src/display.rs +++ b/crates/engine/src/display.rs @@ -93,7 +93,16 @@ pub fn cell_text(wb: &Workbook, sheet: &Sheet, c: CellRef) -> String { /// and no General narrowing (Save As CSV/Text writes this). Formulas give their result. pub fn value_text(wb: &Workbook, sheet: &Sheet, c: CellRef) -> String { let style = wb.styles.get(sheet.style_id(c)); - let f = format(&sheet.value(c), style.num_fmt.as_str(), wb); + let code = style.num_fmt.as_str(); + // A General number keeps full precision here: Excel's Save As CSV/Text (and the clipboard) + // writes the value — up to 15 significant digits (`number_to_text`) — never the narrowing a + // column-width display shows. The grid narrows General itself with the real column width. + if parsed(code).is_general() + && let Value::Number(n) = &sheet.value(c) + { + return gridcraft_core::number_to_text(*n); + } + let f = format(&sheet.value(c), code, wb); match f.fill { Some((_, pos)) => { let mut t = f.text; diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 8510659564..70a2a6d9f9 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File-format parity -> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-12 · **Change:** minor (CSV save keeps the separator it was opened with) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4 +> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-12 · **Change:** minor (CSV save keeps the separator it was opened with; General numbers save at full precision) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4 Every format Excel opens or saves, with GridCraft's read and write support, fidelity and tests. Part of [target-app-parity.md](target-app-parity.md). **File formats: ~50% ready, 80–120 h** @@ -34,9 +34,7 @@ support comes from `crates/engine/src/io.rs` (`FileKind`), `crates/xlsx/src` and | Format | Excel | GridCraft read | GridCraft write | Notes | |---|---|---|---|---| -| `.csv` UTF-8 / Windows / Mac / MS-DOS | R/W | yes (UTF-8 and UTF-16 BOMs, UTF-8, Windows-1252 fallback; delimiter detection) | yes (UTF-8 without BOM, CRLF; a file opened as CSV is saved with the separator it was read with, so a `;` file stays `;`; otherwise `,`) | Excel writes the **displayed** values; we write raw values. No encoding choice on save. Re-import of a single-column export splits text (#127) | -| `.txt` tab-delimited, Unicode text | R/W | yes (`.txt`, `.tsv`, `.tab`) | yes | Text Import Wizard options partly via Text to Columns | -| `.csv` UTF-8 / Windows / Mac / MS-DOS | R/W | yes (UTF-8 and UTF-16 BOMs, UTF-8, Windows-1252 fallback; delimiter detection) | yes (UTF-8 without BOM, CRLF) | Writes the **displayed** values like Excel (number formats applied, formula results, never column-width `#####`). No encoding choice on save. Re-import of a single-column export splits text (#127) | +| `.csv` UTF-8 / Windows / Mac / MS-DOS | R/W | yes (UTF-8 and UTF-16 BOMs, UTF-8, Windows-1252 fallback; delimiter detection) | yes (UTF-8 without BOM, CRLF; a file opened as CSV is saved with the separator it was read with, so a `;` file stays `;`; otherwise `,`) | Writes the **displayed** values like Excel (number formats applied, formula results, never column-width `#####`; General numbers keep full precision, up to 15 significant digits — no column-width scientific notation). No encoding choice on save. Re-import of a single-column export splits text (#127) | | `.txt` tab-delimited, Unicode text | R/W | yes (`.txt`, `.tsv`, `.tab`) | yes (displayed values) | Text Import Wizard options partly via Text to Columns | | `.prn` formatted text (space-delimited) | R/W | no | no | | | `.dif`, `.slk` (SYLK) | R/W | no | no | Small, legacy | @@ -78,6 +76,7 @@ refresh. Counted under features (Get & Transform, ~10% ready), not here. | Date | Change | Summary | |---|---|---| +| 2026-10-12 | minor | CSV/TSV save: General numbers keep full precision (a 12-digit code saved as `1.24412E+11`); duplicate text-format rows merged | | 2026-10-12 | minor | CSV: saving a file opened as CSV keeps its detected separator (`;` files were rewritten with `,`) | | 2026-10-11 | minor | XLSX: cell/shared/array formulas read through the file→model conversion (`_xlpm.` LET/LAMBDA parameter prefixes stripped); table column names keep line breaks; table names may start with `\` | | 2026-10-11 | minor | CSV/TSV export writes displayed values (number formats applied, no `#####`); `.xltx`, `.xltm` and `.xlsm` saved with their own workbook content types | From d85d0d3a7aa13960f3c8467e8fa66e1645d71388 Mon Sep 17 00:00:00 2001 From: Eduardo Soares Date: Mon, 12 Oct 2026 10:47:10 -0300 Subject: [PATCH 2/3] i18n: French gains the two header/footer options every other language has MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Different First Page" and "Different Odd & Even Pages" were missing from fr.rs only, so i18n::tests::translations_are_unique_and_preserve_unknown_text panicked (the invariant: every English string exists in all nine languages). Excel's French labels: «Première page différente», «Pages paires et impaires différentes». --- crates/ui-egui/src/i18n/fr.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ui-egui/src/i18n/fr.rs b/crates/ui-egui/src/i18n/fr.rs index fdf1f891dd..793cbe5f99 100644 --- a/crates/ui-egui/src/i18n/fr.rs +++ b/crates/ui-egui/src/i18n/fr.rs @@ -301,6 +301,8 @@ pub(super) fn translate(text: &str) -> Option<&'static str> { "Add header" => "Autoriser la modification des plages", "Add footer" => "Ajouter un en-tête", "(none)" => "(aucun)", + "Different First Page" => "Première page différente", + "Different Odd & Even Pages" => "Pages paires et impaires différentes", "Header" => "Informations", "Footer" => "Feuille de\nprévision", "Page\nNumber" => "Page précédente", From d012b5d2655cc74df563d7832c6a0ef3adb44ebc Mon Sep 17 00:00:00 2001 From: Eduardo Soares Date: Thu, 5 Nov 2026 09:37:29 -0300 Subject: [PATCH 3/3] #692 review: one .csv and one .txt row in the parity table The merged table kept both the branch's rows and main's; the complete rows stay (General-number precision, separator preservation). --- docs/file-format-parity.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 414ba8d295..ed9fb18205 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -105,8 +105,6 @@ past the parser's limit, and a wrapper inside the text. **Saving writes the real |---|---|---|---|---| | `.csv` UTF-8 / Windows / Mac / MS-DOS | R/W | yes (UTF-8 and UTF-16 BOMs, UTF-8, likely Windows-1256 Arabic detection, otherwise Windows-1252 fallback; delimiter detection; per-column day/month date-order detection for `/` and `-` dates) | yes (UTF-8 without BOM, CRLF; a file opened as CSV is saved with the separator it was read with, so a `;` file stays `;`; otherwise `,`) | Excel writes the **displayed** values — a General number at full precision (15 significant digits), never the narrowing a column-width display shows — and so do we; `file.exportCsv {values: true}` writes raw values (full precision, ISO 8601 dates) for automation. No encoding choice on save. Re-import of a single-column export splits text (#127) A used range that would write more than 512 MiB (two far-apart cells span the whole rectangle) is refused with an error instead of being expanded (#528). | | `.txt` tab-delimited, Unicode text | R/W | yes (`.txt`, `.tsv`, `.tab`; likely Windows-1256 Arabic detection for invalid UTF-8; per-column day/month date-order detection for `/` and `-` dates) | yes | Text Import Wizard options partly via Text to Columns | -| `.csv` UTF-8 / Windows / Mac / MS-DOS | R/W | yes (UTF-8 and UTF-16 BOMs, UTF-8, likely Windows-1256 Arabic detection, otherwise Windows-1252 fallback; delimiter detection; per-column day/month date-order detection for `/` and `-` dates) | yes (UTF-8 without BOM, CRLF) | Writes the **displayed** values like Excel (number formats applied, formula results, never column-width `#####`); `file.exportCsv {values: true}` writes raw values instead. No encoding choice on save. Re-import of a single-column export splits text (#127) A used range that would write more than 512 MiB (two far-apart cells span the whole rectangle) is refused with an error instead of being expanded (#528). | -| `.txt` tab-delimited, Unicode text | R/W | yes (`.txt`, `.tsv`, `.tab`; likely Windows-1256 Arabic detection for invalid UTF-8; per-column day/month date-order detection for `/` and `-` dates) | yes (displayed values) | Text Import Wizard options partly via Text to Columns | | `.prn` formatted text (space-delimited) | R/W | no | no | | | `.slk` SYLK | R/W | **yes, partial** (#1481) | no (Save As `.xlsx`) | Values (numbers, text, booleans, errors), formulas converted from R1C1 to A1 as Excel does (relative and absolute references, ranges, whole rows and columns, shared formulas) with their cached results, number formats (`P`/`F;P`), column widths (`F;W`); the sheet is named after the file. Not read: fonts and cell styles, row heights, names, comments. Non-UTF-8 files are read as Latin-1 | engine `io/tests.rs` (`sylk_*`) | | `.dif` Data Interchange Format | R/W | no | no | Small, legacy |