-
Notifications
You must be signed in to change notification settings - Fork 192
excel cell add
Add cells with values, formulas, and formatting.
Path: /{SheetName}
| 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 |
-
Formula auto-detect: A
valuestarting with=is automatically treated as a formula — no need for a separateformulaproperty. For example,value="=SUM(A1:A10)"works identically toformula="=SUM(A1:A10)". -
Formula prefix: Leading
=sign is automatically stripped from theformulaproperty (e.g.,formula="=SUM(A1:A10)"works the same asformula="SUM(A1:A10)"). -
Array formula literal braces rejected:
formula='{=SUM(...)}'throws — use thearrayformula=...property instead. -
Literal value clears stale formula: writing
value=...on a cell that previously held a formula clears the cached formula. -
Boolean normalization:
type=booleanconvertstrue/yes/1to1, andfalse/no/0to0. -
Conflicting value + formula: supplying both
value=andformula=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:00is converted to the OADate serial. -
Cell-ref path tail:
add /Sheet1/A5 --type cell --prop value=...writes toA5(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
refauto-assigns the next available cell in row 1.
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=FFFF00Inserts 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]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=20Note: 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