Skip to content

Add Xlsx cell style reading support#682

Open
jmcnamara wants to merge 2 commits into
tafia:masterfrom
jmcnamara:xlsx-cell-styles
Open

Add Xlsx cell style reading support#682
jmcnamara wants to merge 2 commits into
tafia:masterfrom
jmcnamara:xlsx-cell-styles

Conversation

@jmcnamara

Copy link
Copy Markdown
Collaborator

This is a smaller version of the PR to add XLSX Styles support to Calamine in #653.

Reviewing that PR was difficult because some recent changes to attribute handling meant that it didn't apply cleanly. It also contained changes for Rich Text and Worksheet Layout in a single commit. So in order to review it I simplified it down to the Style additions and rebased it as best I could while making the changes to the code that I would have requested.

I also added a second commit on top of it that reads the cell information and the style in one read, since that is the use case that most people will have:

xlsx: add combined cell value and style id streaming

Add XlsxCellReader::next_cell_with_style_id() which returns each cell
value together with its style id in a single pass over the worksheet,
avoiding a second read when both values and styles are needed.

I will submit another PR on top of this that gives a more comprehensive Cell reader interface.

Add a `worksheet_style()` API that reads cell formatting (font, fill,
borders, alignment, number format, protection) from XLSX files into an
RLE-compressed StyleRange, plus a streaming `next_style_id()` on
XlsxCellReader. Theme and indexed colors are resolved, including tint.

Inspired by PR tafia#653.

Co-authored-by: David DiMaria <info@collectivesessions.com>
@jmcnamara jmcnamara changed the title Xlsx cell styles Add Xlsx cell styles reading support Jul 15, 2026
@jmcnamara jmcnamara changed the title Add Xlsx cell styles reading support Add Xlsx cell style reading support Jul 15, 2026
Add `XlsxCellReader::next_cell_with_style_id()` which returns each cell
value together with its style id in a single pass over the worksheet,
avoiding a second read when both values and styles are needed. The id
resolves to a full `Style` via the reader's `styles()` palette.
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