You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
formatValue: negative fractions, time rounding, empty zero section, [mm] padding, and decimal rounding differ from Excel #3
formatValue in src/core/xlsx/numfmt.ts (used to format XLSX cells and exported from @p10node/office-engine/core) differs from Excel on negative fractions, sub-second time rounding, empty zero sections, padded elapsed time tokens, and half-way decimal rounding.
Negative fractions get two minus signs (--1 1/2, --1/2): formatFraction already prepends - when v < 0, and formatValue prepends - again for val < 0.
Times truncate instead of rounding to the smallest displayed unit (0:00:00 instead of 0:00:01 for 0.864s, 57:46.0 instead of 57:46.1 for 57m 46.08s): formatDate reads getUTCSeconds() and Math.floor(msec / ...) rather than rounding, unlike TEXT() in src/core/xlsx/formula/dates.ts (which returns "0:00:01" and "23:58:34").
An empty third section (0;-0;;@ or #,##0;(#,##0);) displays "0" instead of "" (Excel number format codes): formatValue guards section 3 with secs[2].toks.length (and TEXT() in src/core/xlsx/formula/format.ts similarly checks sections[2] !== ''), falling back to section 1.
[hh], [mm], and [ss] ignore token width (1:26 instead of 01:26): parseSection discards the bracketed token length and formatDate writes Math.floor(...) without padStart, unlike TEXT() in src/core/xlsx/formula/dates.ts (which returns "01:26").
Fixed decimals call mant.toFixed(decCount) on the raw IEEE-754 double (2.67 and 1.00 instead of 2.68 and 1.01), whereas Excel rounds the 15-significant-digit decimal value as roundHalf in src/core/xlsx/formula/format.ts already does (TEXT(2.675, "0.00") returns "2.68" and TEXT(1.005, "0.00") returns "1.01").
Version: @p10node/office-engine@0.13.2, also on main (715d2aa), Node.js v26.13.0.
Thanks for the report, and for the exact repros. They made this easy to check, and each one is now a test.
All five cases are fixed on main by #16 (thanks to mkroemer for the fix): negative fractions, time rounding, the empty zero section, padded [mm] and half-way decimal rounding. It will be in the next release after v0.13.2.
If you find another format that differs from Excel, please open a new issue.
Activity
pierreneter commentedon Nov 17, 2026
Thanks for the report, and for the exact repros. They made this easy to check, and each one is now a test.
All five cases are fixed on
mainby #16 (thanks to mkroemer for the fix): negative fractions, time rounding, the empty zero section, padded[mm]and half-way decimal rounding. It will be in the next release after v0.13.2.If you find another format that differs from Excel, please open a new issue.