Skip to content

XLSX: leading spaces in an xml:space="preserve" cached formula string are trimmed, so ?-placeholder number formats lose their indent #719

Description

@developer0hye

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
Compare

GT left (Letter), office2pdf right (A4), 150 DPI, Tests sheet page 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions