Skip to content

excel cell add

zmworm edited this page Apr 22, 2026 · 48 revisions

Excel: Cell - add

Add cells with values, formulas, and formatting.

Path: /{SheetName}

Properties

Property Default Description
ref (auto) Cell reference (e.g., A1). If omitted, auto-assigns next available cell in row 1
value Cell value
formula Formula (e.g., =SUM(A1:A10))
type auto string/str, number/num, boolean/bool, date, error (Excel error tokens: #DIV/0!, #N/A, #NAME?, #NULL!, #NUM!, #REF!, #VALUE!)
(style keys) See Cell set for style properties

Notes

  • Formula auto-detect: A value starting with = is automatically treated as a formula — no need for a separate formula property. For example, value="=SUM(A1:A10)" works identically to formula="=SUM(A1:A10)".
  • Formula prefix: Leading = sign is automatically stripped from the formula property (e.g., formula="=SUM(A1:A10)" works the same as formula="SUM(A1:A10)").
  • Array formula literal braces rejected: formula='{=SUM(...)}' throws — use the arrayformula=... property instead.
  • Literal value clears stale formula: writing value=... on a cell that previously held a formula clears the cached formula.
  • Boolean normalization: type=boolean converts true/yes/1 to 1, and false/no/0 to 0.
  • Conflicting value + formula: supplying both value= and formula= emits a warning; the formula wins.
  • Cell length limit: values exceeding Excel's 32767-char per-cell limit are rejected.
  • ISO datetime with time: value=2024-01-15T09:30:00 is converted to the OADate serial.
  • Cell-ref path tail: add /Sheet1/A5 --type cell --prop value=... writes to A5 (path tail honored, not just auto-appended to row 1).
  • Dynamic-array functions: Excel 2016+ dynamic-array functions (FILTER, SORT, SORTBY, UNIQUE, SEQUENCE, RANDARRAY, XLOOKUP, etc.) are auto-prefixed with _xlfn. for legacy compatibility.
  • Auto-ref: Adding a cell without ref auto-assigns the next available cell in row 1.

Examples

officecli add data.xlsx /Sheet1 --type cell --prop ref=A1 --prop value="Hello"
officecli add data.xlsx /Sheet1 --type cell --prop ref=B1 --prop formula="=SUM(A1:A10)"
officecli add data.xlsx /Sheet1 --type cell --prop ref=C1 --prop value=100 --prop type=number --prop bold=true --prop fill=FFFF00

Row add

Inserts a row at the specified index. Existing rows at or below the index automatically shift downward. Merge cells, conditional formatting, data validations, AutoFilter references, and named ranges are all updated.

Property Default Description
cols Number of empty cells to create in the row

Use --index N to specify insertion position (1-based). Omit to append. --from /Sheet1/row[N] copies cells from an existing row (values, formulas, and styles).

officecli add data.xlsx /Sheet1 --type row --index 3
officecli add data.xlsx /Sheet1 --type row --index 3 --prop cols=5
officecli add data.xlsx /Sheet1 --type row --index 5 --from /Sheet1/row[2]

Column add

Inserts a column at the specified position. Existing columns at or after the insert position shift right. Merge cells and named ranges are updated.

Property Default Description
width Column width (characters)

Use --index N (1-based number) or --prop name=C (column letter) to specify the insert position. Both forms are equivalent.

# Insert column at position 3 (shifts existing column C → D)
officecli add data.xlsx /Sheet1 --type col --index 3

# Insert column by letter name
officecli add data.xlsx /Sheet1 --type col --prop name=C

# Insert column with custom width
officecli add data.xlsx /Sheet1 --type col --index 2 --prop width=20

Note: Excel's native path notation (Sheet1!A1, Sheet1!A:A, Sheet1!1:1) is also accepted as an alias for the DOM-style paths (/Sheet1/A1, /Sheet1/col[A], /Sheet1/row[1]).


Based on OfficeCLI v1.0.54

Clone this wiki locally