Skip to content

excel table add

zmworm edited this page Apr 29, 2026 · 51 revisions

Excel: Table - add

Add a table (ListObject) for structured data ranges.

Path: /{SheetName}

Properties

Property Default Description
ref (required) Table range (e.g., A1:D10)
name Table{N} Table name
displayName same as name Display name
style TableStyleMedium2 Table style name. Validated against built-in whitelist + workbook custom styles; unknown names throw.
headerRow / showHeader true First row is header. showHeader=false sets HeaderRowCount=0.
totalRow / showTotals false Show totals row (appended below data, does not overwrite last row)
totalsRowFunction Per-column totals function, comma-separated. Tokens: none, sum, average, count, max, min, stdDev, var, countNums, custom. Each token also emits the matching SUBTOTAL() formula.
columns Column names (comma-separated, e.g., Name,Revenue,Quantity)
showBandedRows true Banded row stripes
showBandedColumns false Banded column stripes
showFirstColumn false Emphasize first column
showLastColumn false Emphasize last column

Examples

officecli add data.xlsx /Sheet1 --type table --prop ref=A1:D10 --prop name="SalesData"
officecli add data.xlsx /Sheet1 --type table --prop ref=A1:C5 --prop name="Summary" --prop style=TableStyleLight1 --prop totalRow=true

Name and column sanitization

Excel refuses to open files that violate its table-schema rules, so officecli normalizes identifiers on add:

  • Table name / displayName parsing as a cell reference (e.g. tbl1 parses as column TBL row 1 within A1:XFD1048576) — auto-suffixed with _ so it no longer looks like a cell reference.
  • Numeric header cells — the header cell is auto-retyped as inlineStr so Excel accepts numeric-looking column names (e.g. "30"). The tableColumn name must match the cell's visible value exactly, so this happens in lockstep.
  • Duplicate column names — auto-deduplicated with a numeric suffix (e.g. Name, Name2, Name3).

Pick unambiguous names like Table1, tbl_1, MyTable to avoid relying on auto-sanitization.


Based on OfficeCLI v1.0.64

Clone this wiki locally