Repository navigation
JSE-18: javascript-excel/format, the number-format renderer - #92
Merged
Merged
Conversation
…eference, changeset
securedeveloper
marked this pull request as ready for review
November 16, 2026 13:26
This was referenced Nov 16, 2026
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.
JSE-18:
javascript-excel/format, the number-format renderer. It renders a value the way Excel shows it in a cell. react-xlsx-viewer 1.0 needs it, and import previews and "as displayed" text can use it too.Release timing: Afzal decided (2026-11-16) that
/formatships in 2.0, with/import, in 2.0.0-alpha.3. The minor changeset goes into that prerelease. The docs say so: the §5.7 intro, the §2 entry table, §3.5.5, §12 Q14, the §13 roadmap row and both READMEs.API (docs/api.md §5.7)
FormattedValuehas{ text, color?, fill?, align }:coloris the section colour as ARGB;fillis a*xrepeat character and its position, not expanded intext. Dates Excel can't show come back as a#fill;alignis Excel's general alignment for the value type.locale(default en-US),date1904,dateZone(forDateinputs only),generalWidth(default 11),indexedColors(for[ColorN]).Date, so the output is the same in every time zone. Viewers read withdates: 'serial'.Dateinputs go throughdateToSerial, like the writer.Coverage
pos;neg;zero;text) and conditions ([>100], …);[Color1]–[Color56](from the workbook palette when given).0 # ?, literals between placeholders (000-00-0000);@, quoted and escaped literals,_xspacing,*xfill;[h] [m] [s];[$€-407]and[$-409]tags (common LCIDs), and the system long-date/time tags[$-F800]/[$-F400]/x-sysdate/x-systime;Intl, so no locale tables ship.Reference: LibreOffice "as shown" export (CI job
LibreOffice)test/format/libreoffice.test.tswrites every case oftest/format/cases.ts, plus every number-formatted cell of conformance files10-number-formatsand11-number-formats-locale, to one workbook. LibreOffice 26.2 exports it to CSV with "save cell contents as shown" in en-US, and each cell is compared withformatCell(cell, { locale: 'en-US' }).?with U+2007: 9;[to verify]in Excel. Conformance file 10 gains a Display sheet whose rows show the expected Excel output for these rules, and docs/conformance.md (regenerated) adds it as an open item for the manual Excel check.Packaging and checks
./formatinexports(withtypesconditions), the tsdown entry,entries.test.ts, the smoke/consumer expectations (runtime and type checks, plus a tree-shaking marker), the TypeDoc entry, and a README section with a type-checked snippet.cellText,dateToSerialand the built-in table from the core.dist/format.jsis 36.2 kB unminified, 11.7 kB gzipped.#,##0.00, 603 ms withyyyy-mm-dd hh:mm, and 1,209 ms with General. That's about 3–6 µs per value.test/format/format.test.ts, with Excel outputs per token class, locales, colours, fills, the 1900 calendar, rounding, odd codes that must not throw, andformatCell.npm test704 passed, publint, smoke (tsc node16/nodenext/bundler; the unused-entry tree-shaking check drops/format), docs snippets, examples and the API reference build.Docs
/import): API, the coverage table, built-in ids, locale, and reference results./import, JSE-20), with both entries kept everywhere.No new dependencies.