Skip to content

word table

goworm edited this page Jul 8, 2026 · 55 revisions

Word: Table

Tables in Word documents with rows and cells, supporting styles, borders, merging, and cell-level formatting.

Path: /body/tbl[N], /body/tbl[N]/tr[M], /body/tbl[N]/tr[M]/tc[K]

Note: cantSplit, nowrap, and hideMark are row/cell-scoped (matching where OOXML stores them) — passing them to add --type table is rejected as UNSUPPORTED. Set them on the row (cantSplit) or cell (nowrap, hideMark) instead — see Table Add / Table Set.

Operations

  • get - Returned attributes and output format

  • add - Add tables, rows, and cells

  • set - Modify table, row, and cell properties

get

officecli get report.docx /body/tbl[1]
officecli get report.docx /body/tbl[1] --depth 3
officecli get report.docx /body/tbl[1]/tr[1]/tc[1]

query

officecli query report.docx "table"

remove

officecli remove report.docx /body/tbl[1]
officecli remove report.docx /body/tbl[1]/tr[3]

Virtual column operations

Word's OOXML has no <w:col> child of <w:tbl> — columns are implicit (<w:gridCol> in <w:tblGrid> plus per-row <w:tc>). v1.0.97 synthesizes a virtual column axis with full add / remove / move / --from (copy-from) parity:

# Insert a column at position 2 (shifts existing col 2 onward) — parent is the table, --type column required
officecli add report.docx /body/tbl[1] --type column --index 2 --prop width=2cm

# Seed text into every new cell of the column
officecli add report.docx /body/tbl[1] --type column --prop text=Header

# Clone column 1's cells (text + style) into a new column
officecli add report.docx /body/tbl[1] --type column --index 3 --from /body/tbl[1]/col[1]

# Remove a column
officecli remove report.docx /body/tbl[1]/col[2]

# Move a column (same-table only)
officecli move report.docx /body/tbl[1]/col[3] --to /body/tbl[1] --index 1

Get/Set/Query at the column level are not implemented — read width via /body/tbl[1] tblGrid or per-cell tcW. Insert is rejected when the column slot crosses a merged cell (gridSpan/vMerge) — unmerge first.

Horizontal merge

Cells accept hMerge for horizontal merge (parity with vertical vMerge). Cell-level hMerge=continue marks continuation cells; hMerge=restart (or omission) is the leading cell.


Based on OfficeCLI v1.0.131

Clone this wiki locally