From c100c46ce0809d591cb755eab26a062cb1d0c1b4 Mon Sep 17 00:00:00 2001 From: Afzal Ahmad Date: Tue, 17 Nov 2026 16:24:44 +0100 Subject: [PATCH 1/3] JSE-F4: built-in formats 37-40 and 47 use Excel's codes Excel for Mac shows #,##0_);(#,##0), #,##0_);[Red](#,##0), #,##0.00_);(#,##0.00), #,##0.00_);[Red](#,##0.00) and mm:ss.0 for the built-in ids 37, 38, 39, 40 and 47 (conformance check, 2026-11-17). The ECMA-376 table, which BUILTIN_NUM_FMTS followed, lists other codes. - BUILTIN_NUM_FMTS and therefore formatValue/formatCell and the render model use Excel's codes. The writer writes only the id, so files are unchanged. - Corpus 10-number-formats: column B shows Excel's codes. - The LibreOffice known-difference rule for 39/40/47 is gone: LibreOffice already used Excel's codes. - Tests: the codes, the _) padding on positives (1,234.50 + space) and mm:ss.0 (31:00.0, 31:00.5). - docs/api.md 11.2 lists Excel's codes and the ECMA ones for reference. --- .changeset/builtin-codes-excel.md | 5 +++++ docs/api.md | 15 +++++++-------- docs/conformance.md | 2 +- packages/javascript-excel/src/numfmt.ts | 16 ++++++++++------ .../javascript-excel/test/conformance/corpus.ts | 8 ++++---- .../javascript-excel/test/format/format.test.ts | 5 ++++- .../test/format/libreoffice.test.ts | 1 - .../javascript-excel/test/read/helpers.test.ts | 2 ++ 8 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 .changeset/builtin-codes-excel.md diff --git a/.changeset/builtin-codes-excel.md b/.changeset/builtin-codes-excel.md new file mode 100644 index 0000000..e95db1f --- /dev/null +++ b/.changeset/builtin-codes-excel.md @@ -0,0 +1,5 @@ +--- +"javascript-excel": patch +--- + +Built-in number formats 37–40 and 47 now use the codes Excel itself shows, checked in Excel for Mac: `#,##0_);(#,##0)`, `#,##0_);[Red](#,##0)`, `#,##0.00_);(#,##0.00)`, `#,##0.00_);[Red](#,##0.00)` and `mm:ss.0`. The ECMA-376 table lists other codes. This changes `BUILTIN_NUM_FMTS` and what `formatValue`/`formatCell` show for those ids: positive numbers keep a trailing space where the `)` would be (`1,234.50 `), and 47 shows `31:00.0` instead of `3100.0`. Files are unaffected, because the writer writes only the id. diff --git a/docs/api.md b/docs/api.md index 2d57732..ecf97d1 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1328,7 +1328,6 @@ Result in CI (LibreOffice 26.2, en-US): 439 probes, 344 identical, 95 different | General | Up to 15 significant digits, no width limit, 3-digit exponents (`0.333333333333333`, `1E+021`) | Fits 11 characters (`0.333333333`, `1E+21`, `1.23457E+11`) | | A decimal point with no digits after it | Dropped: `#,##0.###` shows `7` | Kept: `7.` | | `?` padding | U+2007 FIGURE SPACE | A plain space, as text copied from Excel has | -| Built-in ids 39, 40, 47 | Excel's actual codes, `#,##0.00_);(#,##0.00)` and `mm:ss.0` | The ECMA-376 codes in §11.2 (`#,##0.00;(#,##0.00)`, `mmss.0`). Excel uses LibreOffice's codes *(confirmed in Excel for Mac, 2026-11-17)*; aligned in JSE-F4 | | `am/pm` and `A/P` case | `AM/PM` upper-cased, `A/P` lower-cased | As written in the code | | `b`, `bb`, `bbbb` | Not known; printed as text | The Buddhist-era year (Gregorian + 543) | @@ -1880,7 +1879,7 @@ const bytes = await client.write(workbook, { ### 11.2 Built-in number formats (ECMA-376 §18.8.30) -Ids defined by the spec. Ids 14–17 and 22 render according to the user's locale in Excel even though the spec lists these codes. +Ids defined by the spec. Ids 14–17 and 22 render according to the user's locale in Excel even though the spec lists these codes. For 37–40 and 47 the table has the codes Excel itself uses *(confirmed in Excel for Mac, 2026-11-17; conformance.md, 10-number-formats)*. ECMA-376 lists `#,##0 ;(#,##0)`, `#,##0 ;[Red](#,##0)`, `#,##0.00;(#,##0.00)`, `#,##0.00;[Red](#,##0.00)` and `mmss.0` for them. `BUILTIN_NUM_FMTS` and `formatValue` use Excel's codes from 2.0.0-beta.1. The writer writes only the id for a built-in format, so files are unaffected. | Id | Code | Id | Code | |---|---|---|---| @@ -1889,17 +1888,17 @@ Ids defined by the spec. Ids 14–17 and 22 render according to the user's local | 2 | `0.00` | 20 | `h:mm` | | 3 | `#,##0` | 21 | `h:mm:ss` | | 4 | `#,##0.00` | 22 | `m/d/yy h:mm` | -| 9 | `0%` | 37 | `#,##0 ;(#,##0)` | -| 10 | `0.00%` | 38 | `#,##0 ;[Red](#,##0)` | -| 11 | `0.00E+00` | 39 | `#,##0.00;(#,##0.00)` | -| 12 | `# ?/?` | 40 | `#,##0.00;[Red](#,##0.00)` | +| 9 | `0%` | 37 | `#,##0_);(#,##0)` | +| 10 | `0.00%` | 38 | `#,##0_);[Red](#,##0)` | +| 11 | `0.00E+00` | 39 | `#,##0.00_);(#,##0.00)` | +| 12 | `# ?/?` | 40 | `#,##0.00_);[Red](#,##0.00)` | | 13 | `# ??/??` | 45 | `mm:ss` | | 14 | `mm-dd-yy` | 46 | `[h]:mm:ss` | -| 15 | `d-mmm-yy` | 47 | `mmss.0` | +| 15 | `d-mmm-yy` | 47 | `mm:ss.0` | | 16 | `d-mmm` | 48 | `##0.0E+0` | | 17 | `mmm-yy` | 49 | `@` | -Ids 5–8, 23–36, 41–44 and 50–163 are not in this table: they are reserved or locale-specific (currency, accounting, East Asian dates). The writer accepts them as numbers, but their rendering depends on the user's Excel locale. Prefer custom codes. Excel itself uses different codes for 37–40 and 47 than this ECMA-376 table: `#,##0_);(#,##0)`, `#,##0_);[Red](#,##0)`, `#,##0.00_);(#,##0.00)`, `#,##0.00_);[Red](#,##0.00)` and `mm:ss.0` *(confirmed in Excel for Mac, 2026-11-17; conformance.md, 10-number-formats)*. The engine is aligned with Excel's codes in JSE-F4. +Ids 5–8, 23–36, 41–44 and 50–163 are not in this table: they are reserved or locale-specific (currency, accounting, East Asian dates). The writer accepts them as numbers, but their rendering depends on the user's Excel locale. Prefer custom codes. ### 11.3 Mapping from xlsx-style keys diff --git a/docs/conformance.md b/docs/conformance.md index 47dc49a..ea14bad 100644 --- a/docs/conformance.md +++ b/docs/conformance.md @@ -237,7 +237,7 @@ These facts were marked `[to verify]` in `docs/api.md`. Each one is checked by t | Open item | File | Where | Result | |---|---|---|---| | indent maximum 250 (§3.5.4) | `09-alignment.xlsx` | Alignment!B20 | Confirmed: the cell shows indent 250 and Excel refuses 251. | -| codes and spacing of built-in formats 37–40 and 47 (§11.2) | `10-number-formats.xlsx` | Built-in!C2:C29 | Confirmed, with Excel's own codes: 37 `#,##0_);(#,##0)`, 38 `#,##0_);[Red](#,##0)`, 39 `#,##0.00_);(#,##0.00)`, 40 `#,##0.00_);[Red](#,##0.00)`, 47 `mm:ss.0`. (37 was reported as `#,##0_);#,##0)`, read as a transcription slip for the opening parenthesis; to be confirmed.) Excel uses these codes; the ECMA-376 table in column B and docs/api.md §11.2 differs for all five; aligned in JSE-F4. | +| codes and spacing of built-in formats 37–40 and 47 (§11.2) | `10-number-formats.xlsx` | Built-in!C2:C29 | Confirmed, with Excel's own codes: 37 `#,##0_);(#,##0)`, 38 `#,##0_);[Red](#,##0)`, 39 `#,##0.00_);(#,##0.00)`, 40 `#,##0.00_);[Red](#,##0.00)`, 47 `mm:ss.0`. (37 was reported as `#,##0_);#,##0)`, read as a transcription slip for the opening parenthesis; to be confirmed.) They differ from the ECMA-376 table for all five; column B, `BUILTIN_NUM_FMTS` and docs/api.md §11.2 now use Excel's codes. | | how Excel displays day 0, rounded times, General, a dangling decimal point, am/pm case, conditional sections, built-in id 32 and bbbb (§5.7.4) | `10-number-formats.xlsx` | Display!B2:B17 | **Not verified: the rows that differ were not recorded.** | | ids 27–36 and 50–58 are date formats (§3.4.1) | `11-number-formats-locale.xlsx` | Locale ids!B2:C32 | **Not verified: what these ids show, and in which locale, was not recorded; no East Asian locale was tried.** | | theme index order: 0 = lt1, 1 = dk1, 2 = lt2, 3 = dk2 (§3.5.6) | `12-colours.xlsx` | Theme!B2:B13 | Confirmed: 0 Background 1, 1 Text 1, 2 Background 2, 3 Text 2, 4–9 Accent 1–6, 10 Hyperlink, 11 Followed Hyperlink. | diff --git a/packages/javascript-excel/src/numfmt.ts b/packages/javascript-excel/src/numfmt.ts index b931458..7ba47a6 100644 --- a/packages/javascript-excel/src/numfmt.ts +++ b/packages/javascript-excel/src/numfmt.ts @@ -5,7 +5,11 @@ import type { NumFmt } from "./model"; -/** The built-in number formats ECMA-376 §18.8.30 defines (§11.2). Ids 14–17 and 22 render in the user's locale in Excel. */ +/** + * The built-in number formats ECMA-376 §18.8.30 defines (§11.2), with the codes + * Excel itself uses for 37–40 and 47, which differ from the spec's table + * (checked in Excel for Mac). Ids 14–17 and 22 render in the user's locale in Excel. + */ export const BUILTIN_NUM_FMTS: Readonly> = Object.freeze({ 0: "General", 1: "0", @@ -26,13 +30,13 @@ export const BUILTIN_NUM_FMTS: Readonly> = Object.freeze( 20: "h:mm", 21: "h:mm:ss", 22: "m/d/yy h:mm", - 37: "#,##0 ;(#,##0)", - 38: "#,##0 ;[Red](#,##0)", - 39: "#,##0.00;(#,##0.00)", - 40: "#,##0.00;[Red](#,##0.00)", + 37: "#,##0_);(#,##0)", + 38: "#,##0_);[Red](#,##0)", + 39: "#,##0.00_);(#,##0.00)", + 40: "#,##0.00_);[Red](#,##0.00)", 45: "mm:ss", 46: "[h]:mm:ss", - 47: "mmss.0", + 47: "mm:ss.0", 48: "##0.0E+0", 49: "@", }); diff --git a/packages/javascript-excel/test/conformance/corpus.ts b/packages/javascript-excel/test/conformance/corpus.ts index 139b4b8..7d7d560 100644 --- a/packages/javascript-excel/test/conformance/corpus.ts +++ b/packages/javascript-excel/test/conformance/corpus.ts @@ -88,9 +88,9 @@ const BUILTIN: Array<[number, string, number | Date]> = [ [9, "0%", 0.256], [10, "0.00%", 0.256], [11, "0.00E+00", 1234.5678], [12, "# ?/?", 1.25], [13, "# ??/??", 1.3125], [14, "short date (mm-dd-yy; locale)", new Date(2024, 0, 15)], [15, "d-mmm-yy", new Date(2024, 0, 15)], [16, "d-mmm", new Date(2024, 0, 15)], [17, "mmm-yy", new Date(2024, 0, 15)], [18, "h:mm AM/PM", 0.6458333], [19, "h:mm:ss AM/PM", 0.6458333], [20, "h:mm", 0.6458333], - [21, "h:mm:ss", 0.6458333], [22, "m/d/yy h:mm (locale)", new Date(2024, 0, 15, 15, 30)], [37, "#,##0 ;(#,##0)", -1234], [38, "#,##0 ;[Red](#,##0)", -1234], - [39, "#,##0.00;(#,##0.00)", -1234.5], [40, "#,##0.00;[Red](#,##0.00)", -1234.5], [45, "mm:ss", 0.0215278], [46, "[h]:mm:ss", 1.5215278], - [47, "mmss.0", 0.0215278], [48, "##0.0E+0", 12345.678], [49, "@ (text)", 1234.5678], + [21, "h:mm:ss", 0.6458333], [22, "m/d/yy h:mm (locale)", new Date(2024, 0, 15, 15, 30)], [37, "#,##0_);(#,##0)", -1234], [38, "#,##0_);[Red](#,##0)", -1234], + [39, "#,##0.00_);(#,##0.00)", -1234.5], [40, "#,##0.00_);[Red](#,##0.00)", -1234.5], [45, "mm:ss", 0.0215278], [46, "[h]:mm:ss", 1.5215278], + [47, "mm:ss.0", 0.0215278], [48, "##0.0E+0", 12345.678], [49, "@ (text)", 1234.5678], ]; export const CORPUS: CorpusEntry[] = [ @@ -386,7 +386,7 @@ export const CORPUS: CorpusEntry[] = [ ], }), checks: [ - { where: "Built-in!C2:C29", look: "For each row, open Format Cells > Number > Custom and read the selected code.", expect: "The code matches column B (ids 14 and 22 may show your locale's date format). Write down the exact code Excel shows for ids 37, 38, 39, 40 and 47, including spaces.", verifies: "codes and spacing of built-in formats 37–40 and 47 (§11.2)", result: "Confirmed, with Excel's own codes: 37 `#,##0_);(#,##0)`, 38 `#,##0_);[Red](#,##0)`, 39 `#,##0.00_);(#,##0.00)`, 40 `#,##0.00_);[Red](#,##0.00)`, 47 `mm:ss.0`. (37 was reported as `#,##0_);#,##0)`, read as a transcription slip for the opening parenthesis; to be confirmed.) Excel uses these codes; the ECMA-376 table in column B and docs/api.md §11.2 differs for all five; aligned in JSE-F4." }, + { where: "Built-in!C2:C29", look: "For each row, open Format Cells > Number > Custom and read the selected code.", expect: "The code matches column B (ids 14 and 22 may show your locale's date format). Write down the exact code Excel shows for ids 37, 38, 39, 40 and 47, including spaces.", verifies: "codes and spacing of built-in formats 37–40 and 47 (§11.2)", result: "Confirmed, with Excel's own codes: 37 `#,##0_);(#,##0)`, 38 `#,##0_);[Red](#,##0)`, 39 `#,##0.00_);(#,##0.00)`, 40 `#,##0.00_);[Red](#,##0.00)`, 47 `mm:ss.0`. (37 was reported as `#,##0_);#,##0)`, read as a transcription slip for the opening parenthesis; to be confirmed.) They differ from the ECMA-376 table for all five; column B, `BUILTIN_NUM_FMTS` and docs/api.md §11.2 now use Excel's codes." }, { where: "Custom!B2:B7", look: "Compare column B with column C.", expect: "Everything matches." }, { where: "Display!B2:B17", look: "Compare column B with column C. Widen column B if a value shows ####.", expect: "Everything matches. Write down every row that differs.", verifies: "how Excel displays day 0, rounded times, General, a dangling decimal point, am/pm case, conditional sections, built-in id 32 and bbbb (§5.7.4)", result: "Not verified: the rows that differ were not recorded." }, ], diff --git a/packages/javascript-excel/test/format/format.test.ts b/packages/javascript-excel/test/format/format.test.ts index 80eb7e8..49e9cd2 100644 --- a/packages/javascript-excel/test/format/format.test.ts +++ b/packages/javascript-excel/test/format/format.test.ts @@ -53,10 +53,13 @@ describe("built-in ids (en-US)", () => { [22, 45306.6458333, "1/15/2024 15:30"], [37, 1234, "1,234 "], [37, -1234, "(1,234)"], + [39, 1234.5, "1,234.50 "], [39, -1234.5, "(1,234.50)"], + [40, 1234.5, "1,234.50 "], [45, 0.0215278, "31:00"], [46, 1.5215278, "36:31:00"], - [47, 0.0215278, "3100.0"], + [47, 0.0215278, "31:00.0"], + [47, 0.0215278 + 0.5 / 86_400, "31:00.5"], [48, 12345.678, "12.3E+3"], [49, 1234.5678, "1234.5678"], ])("id %i: %s → %s", (id, v, out) => { diff --git a/packages/javascript-excel/test/format/libreoffice.test.ts b/packages/javascript-excel/test/format/libreoffice.test.ts index c3467b0..e9ec7b7 100644 --- a/packages/javascript-excel/test/format/libreoffice.test.ts +++ b/packages/javascript-excel/test/format/libreoffice.test.ts @@ -46,7 +46,6 @@ const RULES: Rule[] = [ { id: "general", why: "LibreOffice's General shows up to 15 significant digits with no width limit and 3-digit exponents; Excel's General fits the number into 11 characters", test: (p) => code(p) === "General" || code(p) === 0 }, { id: "dangling-point", why: "LibreOffice drops a decimal point with no digits after it (#,##0.### shows 7); Excel keeps it (7.)", test: (_p, lo, ours) => ours.endsWith(".") && lo === ours.slice(0, -1) }, { id: "question-mark-space", why: "LibreOffice pads ? placeholders with U+2007 FIGURE SPACE; formatValue uses a plain space, as text copied from Excel has", test: (_p, lo, ours) => lo.replace(/\u2007/g, " ") === ours }, - { id: "builtin-39-40-47", why: "LibreOffice's built-in ids 39, 40 and 47 are #,##0.00_);(#,##0.00), its [Red] twin and mm:ss.0; formatValue renders the codes of ECMA-376 §18.8.30 (§11.2), which conformance file 10 asks to check in Excel", test: (p, lo, ours) => [39, 40, 47].includes(code(p) as number) && (lo === `${ours} ` || lo === fmt(num(p) ?? 0, "mm:ss.0") || truncated({ ...p, cell: { ...p.cell, style: { numFmt: "mm:ss.0" } } }, lo)) }, { id: "buddhist-year", why: "LibreOffice does not know the b/bb/bbbb Buddhist-era year tokens and prints them as text", test: (p, lo) => typeof code(p) === "string" && /b/i.test(code(p) as string) && /b/i.test(lo) }, { id: "ampm-case", why: "LibreOffice shows am/pm as AM/PM and A/P as a/p; formatValue keeps the case written in the code", test: (_p, lo, ours) => lo.toLowerCase() === ours.toLowerCase() }, { id: "1900-calendar", why: "LibreOffice counts every serial from 1899-12-30, so serials below 61 are one day earlier than in Excel, which keeps the fictitious 1900-02-29 (serial 60) and shows serials below 1 as day 0 (1900-01-00)", test: (p, lo, ours) => (num(p) ?? 99) < 61 && isDateFormat(code(p)) && !truncated(p, lo) && lo.toLowerCase() !== ours.toLowerCase() }, diff --git a/packages/javascript-excel/test/read/helpers.test.ts b/packages/javascript-excel/test/read/helpers.test.ts index 4b99701..1a8c6d4 100644 --- a/packages/javascript-excel/test/read/helpers.test.ts +++ b/packages/javascript-excel/test/read/helpers.test.ts @@ -77,6 +77,8 @@ describe("BUILTIN_NUM_FMTS", () => { it("is the §11.2 table, frozen", () => { expect(Object.keys(BUILTIN_NUM_FMTS).map(Number)).toEqual([0, 1, 2, 3, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 37, 38, 39, 40, 45, 46, 47, 48, 49]); expect(BUILTIN_NUM_FMTS[14]).toBe("mm-dd-yy"); + // Excel's own codes for 37–40 and 47 (checked in Excel for Mac), not the ECMA-376 table's. + expect([37, 38, 39, 40, 47].map((id) => BUILTIN_NUM_FMTS[id])).toEqual(["#,##0_);(#,##0)", "#,##0_);[Red](#,##0)", "#,##0.00_);(#,##0.00)", "#,##0.00_);[Red](#,##0.00)", "mm:ss.0"]); expect(Object.isFrozen(BUILTIN_NUM_FMTS)).toBe(true); for (const [id, code] of Object.entries(BUILTIN_NUM_FMTS)) expect(isDateFormat(code), code).toBe(isDateFormat(Number(id))); }); From ab71bef2904dcb776ad4e47c997eb56751211515 Mon Sep 17 00:00:00 2001 From: Afzal Ahmad Date: Tue, 17 Nov 2026 16:27:18 +0100 Subject: [PATCH 2/3] JSE-F4: update the LibreOffice reference counts in docs/api.md 5.7.4 From the CI LibreOffice job on this branch: 439 probes, 350 identical, 89 different for a known reason, 0 unexplained. --- docs/api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index ecf97d1..80453ac 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1319,7 +1319,7 @@ Excel is the authority; LibreOffice is the automated reference. - **The check.** The `LibreOffice` CI job writes every case of `test/format/cases.ts`, plus every number-formatted cell of the conformance files `10-number-formats` and `11-number-formats-locale`, to one workbook. It has LibreOffice export the workbook to CSV with "save cell contents as shown" in en-US, and compares each cell with `formatCell(cell, { locale: 'en-US' })` (`test/format/libreoffice.test.ts`). - **Where LibreOffice differs.** Every case where LibreOffice is known to differ is listed in that test with LibreOffice's output. The table below records it, with what this module does and why. Each is `[to verify]` against Excel in the conformance checklist. -Result in CI (LibreOffice 26.2, en-US): 439 probes, 344 identical, 95 different for a known reason (1900 calendar 27, time rounding 27, General 12, dangling point 7, built-in ids 39/40/47 7, `?` padding 9, am/pm case 5, Buddhist year 1), 0 unexplained. Every difference has one of the known causes below. Any other difference fails the job. +Result in CI (LibreOffice 26.2, en-US): 439 probes, 350 identical, 89 different for a known reason (1900 calendar 27, time rounding 28, General 12, dangling point 7, `?` padding 9, am/pm case 5, Buddhist year 1), 0 unexplained. Built-in ids 39, 40 and 47 no longer differ: both use Excel's codes (§11.2). One `mm:ss.0` probe now counts under time rounding. Every difference has one of the known causes below. Any other difference fails the job. | Difference | LibreOffice | `formatValue` (Excel's behaviour, `[to verify]`) | |---|---|---| From 750eda9ba0ce4d398755ea54ef7dd909d6968087 Mon Sep 17 00:00:00 2001 From: Afzal Ahmad Date: Tue, 17 Nov 2026 16:30:29 +0100 Subject: [PATCH 3/3] JSE-F4: record the remaining Excel for Mac answers - b: the codes for 37-40 and 47 are the ones copied from Format Cells (37 confirmed exactly, no slip note). Column B held the ECMA codes at the time, so the separate "matched column B" answer is not relied on. - c: no result was reported for the Display sheet; stays not verified. - d: in de-DE, ids 27-36 and 50-58 display as dates; B and C differ with the same pattern (locale separators and date order). East Asian locales were not tried. - h: Excel accepts 30 x's + an emoji (31 code points, 32 UTF-16 units), so the limit counts code points. History was not tried. docs/api.md notes that the writer still counts UTF-16 units, so it is stricter than Excel for such names. --- docs/api.md | 6 +++--- docs/conformance.md | 14 +++++++------- .../javascript-excel/test/conformance/checklist.ts | 4 ++-- .../javascript-excel/test/conformance/corpus.ts | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/api.md b/docs/api.md index 80453ac..ff757e3 100644 --- a/docs/api.md +++ b/docs/api.md @@ -227,10 +227,10 @@ export type ColumnWidth = number | { wch: number } | { wpx: number } | 'auto'; **Sheet names.** The writer throws `INVALID_SHEET_NAME` unless the name: -- is 1 to 31 characters long `[to verify: whether Excel counts UTF-16 code units or code points for astral characters; conformance.md, 17-workbook]`; +- is 1 to 31 characters long. Excel counts code points: it accepts 30 x's and 😀, which is 31 code points and 32 UTF-16 units *(confirmed in Excel for Mac, 2026-11-17; conformance.md, 17-workbook)*. The writer still counts UTF-16 units (`name.length`), so it rejects such a name although Excel accepts it; - contains none of `\ / ? * [ ] :`; - does not start or end with an apostrophe `'`; -- is not `History`, which Excel reserves `[to verify: conformance.md, 17-workbook]`. +- is not `History`, which Excel reserves `[to verify: not tried in the Excel for Mac check; conformance.md, 17-workbook]`. Names must be unique, compared case-insensitively (`DUPLICATE_SHEET_NAME`). `sanitizeSheetName()` (§4.6) makes any string valid. @@ -303,7 +303,7 @@ Excel stores dates as serial numbers. The writer converts `Date` to a serial and **Date detection on read.** A numeric cell is returned as `type: 'date'` with a `Date` value when its number format is a date or time format: - built-in ids 14–22, 45 and 47 (46 is `[h]:mm:ss`, an elapsed time); -- built-in ids 27–36 and 50–58 (locale-dependent East Asian date formats) `[to verify: conformance.md, 11-number-formats-locale]`; +- built-in ids 27–36 and 50–58 (locale-dependent East Asian date formats). Excel for Mac in de-DE displays them as dates *(confirmed in Excel for Mac, 2026-11-17)*; in an East Asian locale `[to verify: not tried; conformance.md, 11-number-formats-locale]`; - custom codes that, after removing quoted literals, backslash escapes and bracketed sections other than the elapsed-time tokens `[h]`, `[m]`, `[s]`, contain a date/time token (`y`, `m`, `d`, `h`, `s`, `AM/PM`, `A/P`, `e`, `g`, `b`) `[to verify against more real-world files; the reader tests cover the common codes]`. Elapsed-time formats (`[h]:mm:ss`) are durations, not dates. The reader returns them as `type: 'number'` and leaves formatting to the caller. With `ReadOptions.dates: 'serial'`, no conversion happens and date cells come back as `type: 'number'`. diff --git a/docs/conformance.md b/docs/conformance.md index ea14bad..e2d40dd 100644 --- a/docs/conformance.md +++ b/docs/conformance.md @@ -6,7 +6,7 @@ This checklist is for a one-time manual check of the conformance corpus in **Mic ## Results -Checked on 2026-11-17 in **Excel for Mac**: every file below opens with no repair prompt, and its checks pass. Six of the open items were confirmed. For three, what Excel showed was not recorded, so they stay open (**Not verified** below). +Checked on 2026-11-17 in **Excel for Mac**: every file below opens with no repair prompt and was reported as passing. Eight of the open items were confirmed, two of them only in part. One (the Display sheet) was not reported. What was not checked is marked **Not verified** below. **Not checked by hand: Excel for Windows and Apple Numbers.** For those apps, only the automated checks apply: CI opens the corpus files in LibreOffice and reads them back with openpyxl and with javascript-excel's own reader ([Automated cross-checks](#automated-cross-checks)). Files saved by Excel, Numbers and Google Sheets (reader fixtures) and a file with a `#SPILL!` error were not made, so those items stay open. @@ -144,7 +144,7 @@ Covers built-in ids the spec does not list: 5–8, 23–36, 41–44, 50–58. | Where | Look at | Expected | Excel Win | Excel Mac | Numbers | |---|---|---|---|---|---| -| Locale ids!B2:C32 | Note what each row shows, in your Excel locale. If you can, switch Excel or Windows to Japanese or Chinese and look again at ids 27–36 and 50–58. | No repair prompt. In an East Asian locale, ids 27–36 and 50–58 show dates; elsewhere they may show General. Record the result for each id. **(open item)** | not checked | opened; result not recorded | not checked | +| Locale ids!B2:C32 | Note what each row shows, in your Excel locale. If you can, switch Excel or Windows to Japanese or Chinese and look again at ids 27–36 and 50–58. | No repair prompt. In an East Asian locale, ids 27–36 and 50–58 show dates; elsewhere they may show General. Record the result for each id. **(open item)** | not checked | see [Open items](#open-items-this-check-resolves) | not checked | ### 12-colours.xlsx: Colours: theme order, tints, indexed palette @@ -202,7 +202,7 @@ Covers document properties (core, app, custom), a non-default workbook font, she |---|---|---|---|---|---| | File > Info > Properties (Advanced Properties > Summary and Custom) | Read the properties. | Title 'Conformance: workbook', subject, author 'Conformance corpus', keywords, comments, category, company 'Example Co', manager. Custom: Project, Build 42, Ratio 0.25, Released No, Checked on 2026-11-16. | not checked | pass | not checked | | Properties!A1 | Look at the font. | Arial 10; Home > Cell Styles > Normal is Arial 10. | not checked | pass | not checked | -| Any sheet tab | Rename a sheet to History. Then rename one to 31 characters made of 30 x's and one emoji (😀). | Record whether Excel refuses 'History' and whether it accepts the 31-character emoji name (if it does, Excel counts characters, not UTF-16 code units). **(open item)** | not checked | opened; result not recorded | not checked | +| Any sheet tab | Rename a sheet to History. Then rename one to 31 characters made of 30 x's and one emoji (😀). | Record whether Excel refuses 'History' and whether it accepts the 31-character emoji name (if it does, Excel counts characters, not UTF-16 code units). **(open item)** | not checked | see [Open items](#open-items-this-check-resolves) | not checked | ### 18-limits.xlsx: Format limits @@ -237,13 +237,13 @@ These facts were marked `[to verify]` in `docs/api.md`. Each one is checked by t | Open item | File | Where | Result | |---|---|---|---| | indent maximum 250 (§3.5.4) | `09-alignment.xlsx` | Alignment!B20 | Confirmed: the cell shows indent 250 and Excel refuses 251. | -| codes and spacing of built-in formats 37–40 and 47 (§11.2) | `10-number-formats.xlsx` | Built-in!C2:C29 | Confirmed, with Excel's own codes: 37 `#,##0_);(#,##0)`, 38 `#,##0_);[Red](#,##0)`, 39 `#,##0.00_);(#,##0.00)`, 40 `#,##0.00_);[Red](#,##0.00)`, 47 `mm:ss.0`. (37 was reported as `#,##0_);#,##0)`, read as a transcription slip for the opening parenthesis; to be confirmed.) They differ from the ECMA-376 table for all five; column B, `BUILTIN_NUM_FMTS` and docs/api.md §11.2 now use Excel's codes. | -| how Excel displays day 0, rounded times, General, a dangling decimal point, am/pm case, conditional sections, built-in id 32 and bbbb (§5.7.4) | `10-number-formats.xlsx` | Display!B2:B17 | **Not verified: the rows that differ were not recorded.** | -| ids 27–36 and 50–58 are date formats (§3.4.1) | `11-number-formats-locale.xlsx` | Locale ids!B2:C32 | **Not verified: what these ids show, and in which locale, was not recorded; no East Asian locale was tried.** | +| codes and spacing of built-in formats 37–40 and 47 (§11.2) | `10-number-formats.xlsx` | Built-in!C2:C29 | Confirmed, with Excel's own codes: 37 `#,##0_);(#,##0)`, 38 `#,##0_);[Red](#,##0)`, 39 `#,##0.00_);(#,##0.00)`, 40 `#,##0.00_);[Red](#,##0.00)`, 47 `mm:ss.0`. These are the codes copied from Format Cells, and they are the record. Column B then held the ECMA-376 codes (`#,##0 ;(#,##0)`, `#,##0 ;[Red](#,##0)`, `#,##0.00;(#,##0.00)`, `#,##0.00;[Red](#,##0.00)`, `mmss.0`), so the separate answer that the codes matched column B is not relied on. Column B, `BUILTIN_NUM_FMTS` and docs/api.md §11.2 now use Excel's codes. | +| how Excel displays day 0, rounded times, General, a dangling decimal point, am/pm case, conditional sections, built-in id 32 and bbbb (§5.7.4) | `10-number-formats.xlsx` | Display!B2:B17 | **Not verified: no result was reported for the Display sheet.** | +| ids 27–36 and 50–58 are date formats (§3.4.1) | `11-number-formats-locale.xlsx` | Locale ids!B2:C32 | Confirmed in de-DE: ids 27–36 and 50–58 display as dates, not General. Columns B and C showed different values with the same pattern, as expected in de-DE (locale separators and date order). **Not verified:** an East Asian locale (Japanese, Chinese) was not tried. | | theme index order: 0 = lt1, 1 = dk1, 2 = lt2, 3 = dk2 (§3.5.6) | `12-colours.xlsx` | Theme!B2:B13 | Confirmed: 0 Background 1, 1 Text 1, 2 Background 2, 3 Text 2, 4–9 Accent 1–6, 10 Hyperlink, 11 Followed Hyperlink. | | indexed 64 = system foreground, 65 = system background (§3.5.6) | `12-colours.xlsx` | Indexed!C66:C67 | Confirmed: 64 is black, 65 is white. | | maximum digit width 7 px for Calibri 11 (§3.3) | `13-columns-rows.xlsx` | Widths!A:F | Confirmed in characters: A 8.43, B 10, C 20, D 12, E 8.43, F 13.57. Pixel widths are Windows values and were not checked. | -| 'History' is reserved; how the 31-character limit counts astral characters (§3.3) | `17-workbook.xlsx` | Any sheet tab | **Not verified: the renames were not recorded.** | +| 'History' is reserved; how the 31-character limit counts astral characters (§3.3) | `17-workbook.xlsx` | Any sheet tab | Confirmed: Excel accepts a name of 30 x's and 😀, 31 code points (32 UTF-16 units), so the limit counts code points. **Not verified:** renaming a sheet to History was not tried. | | 64,000 unique cell formats (§7.2, §11.1) | `18-limits.xlsx` | Opening the file | Confirmed: the file with 64,000 cell formats opens with no repair prompt, and Cmd+End goes to XFD1048576. A file over the limit was not tried. | | how newer Excel errors such as `#SPILL!` are stored (§3.4) | *(make one)* | In Excel 365, enter `=SEQUENCE(3)` in A2 and any value in A3 so it spills into a blocked cell, save as `.xlsx`, and attach the file to the report. The XML is inspected from it. | **Open**: no file was made | diff --git a/packages/javascript-excel/test/conformance/checklist.ts b/packages/javascript-excel/test/conformance/checklist.ts index a680700..9749774 100644 --- a/packages/javascript-excel/test/conformance/checklist.ts +++ b/packages/javascript-excel/test/conformance/checklist.ts @@ -13,7 +13,7 @@ export function renderChecklist(): string { "", "## Results", "", - `Checked on ${MANUAL_CHECK.date} in **${MANUAL_CHECK.checked.join(", ")}**: every file below opens with no repair prompt, and its checks pass. Six of the open items were confirmed. For three, what Excel showed was not recorded, so they stay open (**Not verified** below).`, + `Checked on ${MANUAL_CHECK.date} in **${MANUAL_CHECK.checked.join(", ")}**: every file below opens with no repair prompt and was reported as passing. Eight of the open items were confirmed, two of them only in part. One (the Display sheet) was not reported. What was not checked is marked **Not verified** below.`, "", `**Not checked by hand: ${MANUAL_CHECK.notChecked.join(" and ")}.** For those apps, only the automated checks apply: CI opens the corpus files in LibreOffice and reads them back with openpyxl and with javascript-excel's own reader ([Automated cross-checks](#automated-cross-checks)). Files saved by Excel, Numbers and Google Sheets (reader fixtures) and a file with a \`#SPILL!\` error were not made, so those items stay open.`, "", @@ -53,7 +53,7 @@ export function renderChecklist(): string { "| Open item | File | Where | Result |", "|---|---|---|---|", ); - for (const e of ALL) for (const c of e.checks) if (c.verifies) out.push(`| ${esc(c.verifies)} | \`${e.id}.xlsx\` | ${esc(c.where)} | ${c.result ? (isConfirmed(c) ? esc(c.result) : `**${esc(c.result)}**`) : "**Open**"} |`); + for (const e of ALL) for (const c of e.checks) if (c.verifies) out.push(`| ${esc(c.verifies)} | \`${e.id}.xlsx\` | ${esc(c.where)} | ${c.result ? (isConfirmed(c) ? esc(c.result).replace("Not verified:", "**Not verified:**") : `**${esc(c.result)}**`) : "**Open**"} |`); out.push( "| how newer Excel errors such as `#SPILL!` are stored (§3.4) | *(make one)* | In Excel 365, enter `=SEQUENCE(3)` in A2 and any value in A3 so it spills into a blocked cell, save as `.xlsx`, and attach the file to the report. The XML is inspected from it. | **Open**: no file was made |", "", diff --git a/packages/javascript-excel/test/conformance/corpus.ts b/packages/javascript-excel/test/conformance/corpus.ts index 7d7d560..979d1fd 100644 --- a/packages/javascript-excel/test/conformance/corpus.ts +++ b/packages/javascript-excel/test/conformance/corpus.ts @@ -386,9 +386,9 @@ export const CORPUS: CorpusEntry[] = [ ], }), checks: [ - { where: "Built-in!C2:C29", look: "For each row, open Format Cells > Number > Custom and read the selected code.", expect: "The code matches column B (ids 14 and 22 may show your locale's date format). Write down the exact code Excel shows for ids 37, 38, 39, 40 and 47, including spaces.", verifies: "codes and spacing of built-in formats 37–40 and 47 (§11.2)", result: "Confirmed, with Excel's own codes: 37 `#,##0_);(#,##0)`, 38 `#,##0_);[Red](#,##0)`, 39 `#,##0.00_);(#,##0.00)`, 40 `#,##0.00_);[Red](#,##0.00)`, 47 `mm:ss.0`. (37 was reported as `#,##0_);#,##0)`, read as a transcription slip for the opening parenthesis; to be confirmed.) They differ from the ECMA-376 table for all five; column B, `BUILTIN_NUM_FMTS` and docs/api.md §11.2 now use Excel's codes." }, + { where: "Built-in!C2:C29", look: "For each row, open Format Cells > Number > Custom and read the selected code.", expect: "The code matches column B (ids 14 and 22 may show your locale's date format). Write down the exact code Excel shows for ids 37, 38, 39, 40 and 47, including spaces.", verifies: "codes and spacing of built-in formats 37–40 and 47 (§11.2)", result: "Confirmed, with Excel's own codes: 37 `#,##0_);(#,##0)`, 38 `#,##0_);[Red](#,##0)`, 39 `#,##0.00_);(#,##0.00)`, 40 `#,##0.00_);[Red](#,##0.00)`, 47 `mm:ss.0`. These are the codes copied from Format Cells, and they are the record. Column B then held the ECMA-376 codes (`#,##0 ;(#,##0)`, `#,##0 ;[Red](#,##0)`, `#,##0.00;(#,##0.00)`, `#,##0.00;[Red](#,##0.00)`, `mmss.0`), so the separate answer that the codes matched column B is not relied on. Column B, `BUILTIN_NUM_FMTS` and docs/api.md §11.2 now use Excel's codes." }, { where: "Custom!B2:B7", look: "Compare column B with column C.", expect: "Everything matches." }, - { where: "Display!B2:B17", look: "Compare column B with column C. Widen column B if a value shows ####.", expect: "Everything matches. Write down every row that differs.", verifies: "how Excel displays day 0, rounded times, General, a dangling decimal point, am/pm case, conditional sections, built-in id 32 and bbbb (§5.7.4)", result: "Not verified: the rows that differ were not recorded." }, + { where: "Display!B2:B17", look: "Compare column B with column C. Widen column B if a value shows ####.", expect: "Everything matches. Write down every row that differs.", verifies: "how Excel displays day 0, rounded times, General, a dangling decimal point, am/pm case, conditional sections, built-in id 32 and bbbb (§5.7.4)", result: "Not verified: no result was reported for the Display sheet." }, ], }, { @@ -418,7 +418,7 @@ export const CORPUS: CorpusEntry[] = [ look: "Note what each row shows, in your Excel locale. If you can, switch Excel or Windows to Japanese or Chinese and look again at ids 27–36 and 50–58.", expect: "No repair prompt. In an East Asian locale, ids 27–36 and 50–58 show dates; elsewhere they may show General. Record the result for each id.", verifies: "ids 27–36 and 50–58 are date formats (§3.4.1)", - result: "Not verified: what these ids show, and in which locale, was not recorded; no East Asian locale was tried.", + result: "Confirmed in de-DE: ids 27–36 and 50–58 display as dates, not General. Columns B and C showed different values with the same pattern, as expected in de-DE (locale separators and date order). Not verified: an East Asian locale (Japanese, Chinese) was not tried.", }, ], }, @@ -657,7 +657,7 @@ export const CORPUS: CorpusEntry[] = [ look: "Rename a sheet to History. Then rename one to 31 characters made of 30 x's and one emoji (😀).", expect: "Record whether Excel refuses 'History' and whether it accepts the 31-character emoji name (if it does, Excel counts characters, not UTF-16 code units).", verifies: "'History' is reserved; how the 31-character limit counts astral characters (§3.3)", - result: "Not verified: the renames were not recorded.", + result: "Confirmed: Excel accepts a name of 30 x's and 😀, 31 code points (32 UTF-16 units), so the limit counts code points. Not verified: renaming a sheet to History was not tried.", }, ], },