Skip to content

excel cell set

zmworm edited this page Mar 31, 2026 · 23 revisions

Excel: Cell - set

Modify cell content, style, and row/column properties.

Path: /{SheetName}/A1, /{SheetName}/A1:D10, /{SheetName}/row[N], /{SheetName}/col[A]

Content Properties

Property Accepted Values Description
value any Cell value
formula formula string Cell formula (e.g., =SUM(A1:A10)). Leading = is auto-stripped
type string/str, number/num, boolean/bool Value type
clear (any value) Clear content, formula, and style
link URL or none Hyperlink

Style Properties

Property Accepted Values Description
font.name font name Font family
font.size number (pt) Font size
font.bold / bold bool Bold
font.italic / italic bool Italic
font.strike / strike / font.strikethrough bool Strikethrough
font.underline / underline true, false, single, double Underline
font.color hex RGB Font color
superscript / font.superscript bool Superscript text
subscript / font.subscript bool Subscript text
vertalign superscript, subscript Vertical text alignment
fill / bgcolor hex RGB, gradient Background fill (see below)
numFmt / numberFormat format code Number format (e.g., 0%, #,##0.00)
alignment.horizontal / halign left, center, right, justify Horizontal alignment
alignment.vertical / valign top, center, bottom Vertical alignment
alignment.wrapText / wrap bool Wrap text
rotation / textrotation 0-180, or 255 Text rotation (255 = vertical)
indent 0-15 Text indent level
shrinkToFit / shrink bool Shrink text to fit cell
border.all border style All borders
border.left / border.right / border.top / border.bottom border style Per-side border
border.color hex RGB All border colors
border.*.color hex RGB Per-side border color (e.g., border.left.color)

Gradient fill: Use fill=FF0000-0000FF for a linear gradient (default angle 0), fill=FF0000-0000FF-90 to specify angle in degrees, or fill=radial:FF0000-0000FF for a radial gradient.

Theme colors: font.color and fill accept theme color names as input and return them on readback: lt1, dk1, lt2, dk2, accent1accent6, hlink, folHlink.

Border styles: thin, medium, thick, double, dashed, dotted, dashDot, dashDotDot, hair, mediumDashed, mediumDashDot, mediumDashDotDot, slantDashDot, none

Number formats: general, 0, 0.00, #,##0, #,##0.00, 0%, 0.00%, or custom format codes

Cell Examples

officecli set data.xlsx /Sheet1/A1 --prop value="Updated"
officecli set data.xlsx /Sheet1/A1 --prop bold=true --prop font.size=14 --prop font.color=FF0000
officecli set data.xlsx /Sheet1/A1 --prop fill=FFFF00 --prop halign=center --prop wrap=true
officecli set data.xlsx /Sheet1/A1 --prop border.all=thin --prop border.color=000000
officecli set data.xlsx /Sheet1/A1 --prop numberFormat="#,##0.00"
officecli set data.xlsx /Sheet1/A1 --prop rotation=45 --prop indent=2
officecli set data.xlsx /Sheet1/A1 --prop shrinkToFit=true
officecli set data.xlsx /Sheet1/A1 --prop fill=FF0000-0000FF-90
officecli set data.xlsx /Sheet1/A1 --prop fill=radial:FF0000-0000FF

Cell Protection

Property Accepted Values Description
locked bool Lock cell when sheet is protected (default: true)
formulahidden bool Hide formula in formula bar when sheet is protected (default: false)

Protection only takes effect when the sheet itself is protected (see Sheet set).

officecli set data.xlsx /Sheet1/A1 --prop locked=false
officecli set data.xlsx /Sheet1/B1 --prop locked=true --prop formulahidden=true

Rich Text Runs

Individual text runs within a cell can be set by path:

Path: /{SheetName}/A1/run[N] (1-based)

Property Description
text / value Run text content
bold, italic, strike Text style
underline true, false, single, double
superscript, subscript Vertical alignment
size Font size (pt)
color Font color (hex)
font Font family name
officecli set data.xlsx /Sheet1/A1/run[1] --prop bold=true --prop color=FF0000
officecli set data.xlsx /Sheet1/A1/run[2] --prop superscript=true

Array Formulas

Property Description
arrayformula Array formula expression (e.g., {=SUM(A2:A10*B2:B10)})
officecli set data.xlsx /Sheet1/A1 --prop "arrayformula={=SUM(A2:A10*B2:B10)}"

Range set

Style and content properties (bold, color, font size, etc.) are applied to every cell in the range individually. Range-level properties (merge, height, width) apply to the range as a whole.

Property Accepted Values Description
merge bool true = merge, false = unmerge
officecli set data.xlsx /Sheet1/A1:D1 --prop merge=true
officecli set data.xlsx /Sheet1/A1:D1 --prop merge=false

# Apply formatting to every cell in range
officecli set data.xlsx /Sheet1/A1:D10 --prop bold=true --prop font.color=FF0000

Row set

Property Accepted Values Description
height number (points) Row height
hidden bool Hide/show row
officecli set data.xlsx /Sheet1/row[1] --prop height=30
officecli set data.xlsx /Sheet1/row[3] --prop hidden=true

Column set

Property Accepted Values Description
width number (characters) Column width
hidden bool Hide/show column
officecli set data.xlsx /Sheet1/col[A] --prop width=20
officecli set data.xlsx /Sheet1/col[B] --prop hidden=true

Based on OfficeCLI v1.0.28

Clone this wiki locally