Summary
Cached formula string values stored with xml:space="preserve" lose their leading spaces
during parsing, so number formats that use ? placeholders to align digits print flush
left instead of indented. The ? placeholder reserves a digit-width space; Excel writes
the resulting alignment spaces into the cached <v> text and preserves them via
xml:space="preserve".
Measured
NumberFormatTests.xlsx Tests sheet rows 44–46 (Lucida Sans Typewriter 10pt): cached
values ' 1,234,567' / ' 1,234,567' / ' 1,234,567' (1/2/4 leading spaces).
|
GT (Excel) |
office2pdf |
| rows 44–46 rendering |
indented by ~6.0 / 12.1 / 24.1pt |
all flush as 1,234,567 |
Reproduction
cargo run -p office2pdf-cli -- tests/fixtures/xlsx/poi/NumberFormatTests.xlsx -o out.pdf
pdftotext out.pdf - | grep -n "1,234,567" # leading spaces gone; GT keeps 1/2/4 spaces
Expected
Leading and trailing spaces in an xml:space="preserve" cached value survive to the text
layer and the rendered indent matches Excel's.
Actual
The spaces are trimmed and the ?-placeholder indent collapses.
Related: #621
Found in: the #621 fix-PR visual audit (NumberFormatTests.xlsx Tests sheet p1, local Excel-for-Mac GT, 150 DPI, 2026-07-30). Visual comparison below.
Visual comparison
| Compare |
 |
GT left (Letter), office2pdf right (A4), 150 DPI, Tests sheet page 1.
Summary
Cached formula string values stored with
xml:space="preserve"lose their leading spacesduring parsing, so number formats that use
?placeholders to align digits print flushleft instead of indented. The
?placeholder reserves a digit-width space; Excel writesthe resulting alignment spaces into the cached
<v>text and preserves them viaxml:space="preserve".Measured
NumberFormatTests.xlsxTests sheet rows 44–46 (Lucida Sans Typewriter 10pt): cachedvalues
' 1,234,567'/' 1,234,567'/' 1,234,567'(1/2/4 leading spaces).1,234,567Reproduction
Expected
Leading and trailing spaces in an
xml:space="preserve"cached value survive to the textlayer and the rendered indent matches Excel's.
Actual
The spaces are trimmed and the
?-placeholder indent collapses.Related: #621
Found in: the #621 fix-PR visual audit (NumberFormatTests.xlsx Tests sheet p1, local Excel-for-Mac GT, 150 DPI, 2026-07-30). Visual comparison below.
Visual comparison
GT left (Letter), office2pdf right (A4), 150 DPI, Tests sheet page 1.