#455·OfficeCLI

feat(xlsx): apply a named cell style (cellStyles) through a `style` prop on cell/range

Author: Th3R3alDuk3Created Sep 30, 2026Updated Sep 30, 2026

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:

json
{"command": "set", "path": "/Sheet1/B2:F2", "props": {"style": "Header"}}

Engine behaviour, following what Excel does when a style is applied:

  1. Look up cellStyle[@name] → xfId, and its master format cellStyleXfs/xf[xfId].
  2. Find or append a cellXfs/xf that has xfId set to that id and copies the master's numFmtId, fontId, fillId, borderId and alignment/protection children (with the matching apply* flags); bump cellXfs/@count.
  3. Set the cell's s attribute 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.