Skip to content

JSE-F4: built-in formats 37-40 and 47 use Excel's codes - #120

Merged
securedeveloper merged 3 commits into
mainfrom
jse-f4-builtin-codes
Nov 17, 2026
Merged

securedeveloper merged 3 commits into
mainfrom
jse-f4-builtin-codes

Conversation

@securedeveloper

@securedeveloper securedeveloper commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

The manual conformance check in Excel for Mac (2026-11-17) recorded the codes Excel shows for the built-in number formats 37–40 and 47. All five differ from the ECMA-376 table that BUILTIN_NUM_FMTS followed, and match what LibreOffice already used:

id before (ECMA-376) now (Excel)
37 #,##0 ;(#,##0) #,##0_);(#,##0)
38 #,##0 ;[Red](#,##0) #,##0_);[Red](#,##0)
39 #,##0.00;(#,##0.00) #,##0.00_);(#,##0.00)
40 #,##0.00;[Red](#,##0.00) #,##0.00_);[Red](#,##0.00)
47 mmss.0 mm:ss.0

These are the codes copied from Excel's Format Cells dialog, and they are the record. Column B of the corpus held the ECMA-376 codes at the time, so the separate answer that the codes "matched column B" is not relied on.

What changes

  • BUILTIN_NUM_FMTS (public export), and therefore formatValue, formatCell and the render model, for these ids:
    • 39 and 40 positives: 1,234.50 becomes 1,234.50 (the _) padding).
    • 37 and 38 positives: still 1,234 . The ECMA code had a literal space; Excel's has _).
    • Negatives are unchanged: (1,234.50).
    • 47: 3100.0 becomes 31:00.0.
  • Files are not affected. The writer writes only numFmtId for a built-in id and never the code.
  • Corpus 10-number-formats.xlsx: column B of the Built-in sheet now shows Excel's codes, so the corpus file's bytes change. No other corpus file or golden test changes.
  • test/format/libreoffice.test.ts: the known-difference rule builtin-39-40-47 is removed, because LibreOffice and formatValue now agree on those probes. The CI LibreOffice job shows this (no unexplained differences).
  • docs/api.md §11.2: lists Excel's codes, with the ECMA ones for reference. The §5.7.4 row for 39/40/47 is removed.

The other manual-check answers (docs only)

Recorded in test/conformance/corpus.ts, which regenerates docs/conformance.md, and in docs/api.md:

  • h: Excel for Mac accepts 30 × x + 😀 as a sheet name, which is 31 code points and 32 UTF-16 units, so the 31-character limit counts code points: confirmed. Renaming a sheet to History was not tried, so that stays not verified. Note: the writer's validateSheetName counts UTF-16 units (name.length), so it is stricter than Excel and rejects such a name. That is not changed here.
  • d: in de-DE, ids 27–36 and 50–58 display as dates, not General: confirmed for de-DE. B and C differ with the same pattern, as expected (locale separators and date order). East Asian locales were not tried, so they stay not verified.
  • c: no result was reported for the Display sheet, so it stays not verified.

Tests

  • test/read/helpers.test.ts: the five codes.
  • test/format/format.test.ts: _) padding on 39/40 positives, mm:ss.0 (31:00.0 and 31:00.5).
  • Full suite: 945 pass.

Patch changeset (builtin-codes-excel).

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.
From the CI LibreOffice job on this branch: 439 probes, 350 identical,
89 different for a known reason, 0 unexplained.
- 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.
@securedeveloper
securedeveloper merged commit aa64070 into main Nov 17, 2026
9 checks 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.

1 participant