feat(document): style a cell of an ods file - #936
Merged
Merged
Conversation
andiwand
force-pushed
the
fix/xlsx-cell-style-read
branch
from
September 28, 2026 18:31
2f0eaa3 to
1eb3554
Compare
Sheet::set_cell_style and the setCellStyle op write the fill, the horizontal alignment, and bold, italic, underline, strikethrough, colour and size onto one cell. The op takes the keys of setTextStyle, and fill and align in place of highlight. The ods writer claims the cell as a value write does, and points table:style-name at a fresh automatic ce<n> style. That style copies the automatic style the cell shows (its own, else the row or column default) with the delta, or inherits from a named one. One base and one delta make one style, so a range of cells adds one. A covered position now refuses a value and a style. The index holds no covered cell, so is_covered walks the row. claim_cell took the start of a run from the end of the cell before it, which is wrong after a span; it now takes it from the run itself. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NXnz6EZY8YpyiyyE1GpsWy
`write_text_properties` had its own copy of `set_attribute`, so it now calls that. The lambda that builds the key of a cell style is `key_of`, because `optional` reads like `std::optional`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tigcf9he3w1aHfNPJoEGsd
andiwand
force-pushed
the
feat/ods-cell-style
branch
from
September 28, 2026 18:59
2487baa to
4595df3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 2 of the cell-formatting plan (#934).
Change
Sheet::set_cell_style(column, row, TableCellStyle, TextStyle)and thesetCellStyleop:{"op": "setCellStyle", "sheet": 0, "column": 1, "row": 2, "style": {"fill": "#ffff00", "bold": true, "align": "center"}}The keys are those of
setTextStyle, plusfill(#rrggbbor null) andalign(left,center,right).highlightrefuses, and so does any style field that no engine writes.The ods writer claims the cell as a value write does, and points
table:style-nameat a fresh automaticce<n>style. That style copies the automatic style that the cell shows (its own, else the row or column default) with the delta, or it inherits from a named style. One base and one delta make one style, so formatting a range adds one style and not one per cell.The fill is
fo:background-color, the alignment isfo:text-alignwithstyle:text-align-source="fix", and the text keys are written assetTextStylewrites them.Other engines refuse, because the hook's default throws. xlsx comes in the next PR.
Two fixes found on the way
is_coverednow walks the row in the DOM, and both writes refuse.claim_celltook the start of a run from the end of the cell before it. After a span that is wrong, so a write into an empty cell right of a merge threw. It now takes the start from the run itself. The regression test fails without the fix.Proof
OdfSheetStyletests on inline flat sheets: a shared style is copied, a named one is inherited from, a repeated run is cut, a cell past the sheet is made, one delta makes one style, a fill taken away istransparent, alignment, a formula cell, refusals and the JSON op.Senza nome 1.odsstyled with seven ops and saved: LibreOffice loads it and shows every op as written: fills, bold, italic, underline, colour, strikethrough at 16pt, a fill taken away, and a cell grown past the table. Our own render of the saved file matches.🤖 Generated with Claude Code
https://claude.ai/code/session_01NXnz6EZY8YpyiyyE1GpsWy