-
Notifications
You must be signed in to change notification settings - Fork 517
excel cell set
Modify cell content, style, and row/column properties.
Path: /{SheetName}/A1, /{SheetName}/A1:D10, /{SheetName}/row[N], /{SheetName}/col[A]
| Property | Accepted Values | Description |
|---|---|---|
value |
any | Cell value. Honors existing text numberformat across two-step Set (the cell's stored format is preserved when only the value changes). |
formula |
formula string | Cell formula (e.g., =SUM(A1:A10)). Leading = is auto-stripped. Cell-ref bounds validated (rows 1..1048576, cols A..XFD). |
type |
string/str, number/num, boolean/bool, error, richtext
|
Value type. richtext accepts a runs= array (symmetric with cell add). Explicit type=date rejects unparsable date strings. |
merge (range path) |
range or empty/false | On a range path (/Sheet1/A1:C3), merge="A1:C3" or true merges; empty string or false clears existing merges in the range. |
clear |
(any value) | Clear content, formula, and style |
link |
URL or none
|
Hyperlink. Internal references (#Sheet!A1) are written as the location attr. |
tooltip / screenTip
|
text | Hyperlink tooltip (@tooltip). Set alone updates the tooltip without touching the URL. |
| Property | Accepted Values | Description |
|---|---|---|
font.name |
font name | Font family |
font.size / 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 or scheme name | Font color. Accepts hex (FF0000/#FF0000) or full OOXML scheme color names: accent1–accent6, lt1/lt2, dk1/dk2, bg1/bg2, tx1/tx2, hlink, folHlink. |
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 |
direction / dir
|
rtl / ltr / context
|
Reading order (alias for alignment.readingOrder). See i18n. |
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, accent1–accent6, 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
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| 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=trueIndividual 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| 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)}"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 or comma-list or sweep
|
true = merge, false = unmerge (range must exactly match an existing merged region — fails loudly otherwise; use sweep to clear all merges that intersect the range). Comma-separated ranges (e.g. merge="A1:B2,D1:E2") create separate merge regions in a single call. |
sort |
COL DIR[, COL DIR ...] |
Sort rows within the range (see Sheet set — Sort) |
sortHeader |
bool | Treat the first row of the range as a header |
officecli set data.xlsx /Sheet1/A1:D1 --prop merge=true
officecli set data.xlsx /Sheet1/A1:D1 --prop merge=false
# Sort a specific range
officecli set data.xlsx '/Sheet1/A1:D100' --prop sort="B desc" --prop sortHeader=true
# Apply formatting to every cell in range
officecli set data.xlsx /Sheet1/A1:D10 --prop bold=true --prop font.color=FF0000| Property | Accepted Values | Description |
|---|---|---|
height |
number or unit-qualified | Row height. Accepts bare numbers (points) or unit-qualified strings: 40pt, 40px, 1cm, 0.5in. |
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| Property | Accepted Values | Description |
|---|---|---|
width |
number or unit-qualified | Column width. Accepts bare numbers (character units) or unit-qualified strings: 40pt, 40px, 1cm, 0.5in (converted via 7px/char). |
hidden |
bool | Hide/show column |
officecli set data.xlsx /Sheet1/col[A] --prop width=20
officecli set data.xlsx /Sheet1/col[B] --prop hidden=trueBased on OfficeCLI v1.0.64