feat(xlsx): apply a named cell style (cellStyles) through a `style` prop on cell/range
Summary
set cell / set range for xlsx offer direct formatting props (font.*, fill, border.*, numberFormat, alignment), but there is no way to apply one of the workbook's named cell styles (styles.xml → cellStyles/cellStyle/@name, e.g. "Header", "Total", "Input" in a corporate template). Checked against officecli help xlsx cell --json on v1.0.152: no style/cellStyle prop; style exists only for add table.
Why it matters
Templates carry their design in named styles. An agent that fills a template should be able to say "make B2:F2 a Header cell" instead of re-typing font, fill and border values, and the result should stay linked to the style (xfId) so that editing the style in Excel later updates the cells.
Proposal
A style (or cellStyle, to avoid confusion with the table prop) prop on set for cell and range, taking a name from cellStyles:
{"command": "set", "path": "/Sheet1/B2:F2", "props": {"style": "Header"}}Engine behaviour, following what Excel does when a style is applied:
- Look up
cellStyle[@name]→xfId, and its master formatcellStyleXfs/xf[xfId]. - Find or append a
cellXfs/xfthat hasxfIdset to that id and copies the master'snumFmtId,fontId,fillId,borderIdand alignment/protection children (with the matchingapply*flags); bumpcellXfs/@count. - Set the cell's
sattribute to that index.
Nice to have: get/query cell read the applied style name back (style: "Header"), and an error listing the workbook's style names when the name is unknown (like the "Available layouts" error for pptx).
Current workaround
We resolve this ourselves before calling OfficeCLI: parse styles.xml, append the missing cellXfs entries via raw-set, and rewrite a set style into a raw-set … setattr s=<index> with an XPath over the range. It works, but it is ~100 lines of OOXML handling outside the engine, so we would much rather see it in OfficeCLI. Happy to test a build.
Source: iOfficeAI/OfficeCLI