Skip to content

feat(xls): cell font and fill formatting from Font/XF/Palette records#606

Open
andiwand wants to merge 3 commits into
mainfrom
feat/xls-cell-formatting
Open

feat(xls): cell font and fill formatting from Font/XF/Palette records#606
andiwand wants to merge 3 commits into
mainfrom
feat/xls-cell-formatting

Conversation

@andiwand

@andiwand andiwand commented Jul 16, 2026

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Adds per-cell character formatting to the legacy .xls decoder: font name, size, bold, italic, underline, strikethrough, font color, and cell fill (background) color, replacing the flat font_size = 11pt placeholder.

How

  • Globals pass now collects Font (0x0031), XF (0x00E0) and Palette (0x0092) records; every cell record's ixfe (previously read and discarded) is kept on its SheetCell.
  • Every XF is resolved once at parse time into a CellStyle (TextStyle from the font + TableCellStyle fill), stored in the registry indexed by ixfe. Adapters only look up: text_style/paragraph_text_style via the sheet_cell ancestor, sheet_cell_style for the fill. No renderer changes needed.
  • Handles the spec's corner cases: FontIndex 4 does not exist (ifnt < 4 zero-based, > 4 one-based, [MS-XLS] 2.5.129); Icv color table with built-ins, custom-palette override and default palette ([MS-XLS] 2.5.161); automatic/system colors left unset; dyHeight == 0 leaves the size unset instead of emitting invisible 0pt text; non-solid fill patterns approximated by their foreground color.

Tests

  • OldMs.xls_cell_styles — synthetic inline-byte workbook: font resolution incl. the index-4 gap, all style flags, default palette, automatic color, solid fill, unstyled empty positions.
  • OldMs.xls_palette_recordPalette record overriding the default palette.
  • All existing OldMs.* and xls HtmlOutputTests pass.

Note: reference HTML

The rendered spreadsheet HTML changes (real fonts instead of 11pt), e.g. the bold header row of file_example_XLS_10.xls:

-<x-s style="font-size:11pt;">First Name</x-s>
+<x-s style="font-family:Arial;font-size:10pt;font-weight:bold;font-style:normal;">First Name</x-s>

The 6 xls reference outputs under test/data/reference-output/odr-public/output/xls/ need regenerating for the compare-html CI step (needs a push to the reference repo — flagged separately).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 971dd7d08f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/odr/internal/oldms/spreadsheet/xls_document.cpp
andiwand and others added 2 commits July 19, 2026 10:38
Parse the Font (0x0031), XF (0x00E0) and Palette (0x0092) records in the
globals substream, keep each cell's ixfe, and resolve every XF into a
per-cell TextStyle (name, size, weight, italic, underline, strike, color)
plus a TableCellStyle fill. Replaces the flat 11pt placeholder style.

Covers the FontIndex 4 gap ([MS-XLS] 2.5.129), the Icv color table with
custom-palette override ([MS-XLS] 2.5.161), and approximates non-solid
fill patterns by their foreground color.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R9Z3kyUaHNkJacAEggevHH
@andiwand
andiwand force-pushed the feat/xls-cell-formatting branch from f7b0441 to c0a60e4 Compare July 19, 2026 08:38
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