-
Notifications
You must be signed in to change notification settings - Fork 528
excel cell add
Add cells with values, formulas, and formatting.
Path: /{SheetName}
| Property | Default | Description |
|---|---|---|
ref / address
|
(auto) | Cell reference (e.g., A1). If omitted, auto-assigns next available cell in row 1. Note: path is rejected with a hint to use ref or address. |
shift |
- | Cell-level insert direction — right or down (Excel UI's Insert Cells... dialog). Only cellRefs within the affected row/column are updated; for full-band insert with formula refs/CF/DV/hyperlinks/tables adjusted across the whole sheet, use add --type row / add --type col instead. |
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!) |
phonetic |
string | Japanese furigana / CJK ruby reading. Promotes the cell text into the SST, appends a single <rPh> spanning the entire base text, and seeds <phoneticPr> with FullWidthKatakana / Distributed defaults. Get surfaces it as phonetic=.... Multi-segment phonetic runs are out of scope; use raw OOXML for finer slicing. |
| (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月15日T09: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. -
OFFSET / INDIRECT: the calc engine now produces reference values for
OFFSETandINDIRECT, so=OFFSET(A1,0,0)resolves rather than returningnull. Defined names whose body is a formula (e.g.=OFFSET(...)) are inlined at parse time. -
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=FFFF00
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, named ranges, hyperlinks, table refs, and formula references are all rewritten across the sheet (Path A: regex-based). Cell-content shorthand: pass c1=/c2=/c3= to seed values into the inserted row's cells in order.
| Property | Default | Description |
|---|---|---|
cols |
Number of empty cells to create in the row | |
c{N} |
Seed cell content at the {N}th column (e.g. c1=Name --prop c2=Score) |
Use --index N to specify insertion position (1-based). Omit to append. --from /Sheet1/row[N] (or --from /Sheet1/col[L]) copies cells from an existing row/col with values, formulas, and styles; formula refs are delta-shifted to match the destination row/col.
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] officecli add data.xlsx /Sheet1 --type row --index 6 --prop c1=Alice --prop c2=42
Inserts a column at the specified position. Existing columns at or after the insert position shift right. Merge cells, named ranges, conditional formatting, data validations, AutoFilter, hyperlinks, table refs, and formula references are all rewritten across the sheet.
| 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.97