Repository navigation
word table set
goworm edited this page Jul 8, 2026
·
55 revisions
Modify table, row, and cell properties.
Path: /body/tbl[N]
| Property | Accepted Values | Description |
|---|---|---|
style |
style ID | Table style |
alignment |
left, center, right
|
Alignment |
width |
twips or percentage | Width |
indent |
twips | Indent |
cellSpacing |
twips | Cell spacing |
layout |
fixed, auto
|
Layout mode |
padding |
twips | Default cell padding |
border.* |
border format | Borders (.all, .top, .bottom, .left, .right, .insideH, .insideV) |
caption |
text | Accessibility caption for the table (<w:tblCaption>) |
tblLook |
4-digit hex | Conditional-formatting bitmask selecting which facets of a conditional/banded style apply (0x0020 firstRow, 0x0040 lastRow, 0x0080 firstColumn, 0x0100 lastColumn, 0x0200 noHBand, 0x0400 noVBand). Decomposed facets also settable as tblLook.firstRow etc. |
officecli set report.docx /body/tbl[1] --prop alignment=center --prop width=100%
officecli set report.docx /body/tbl[1] --prop "border.all=single;4;000000;0"Path: /body/tbl[N]/tr[M]
| Property | Accepted Values | Description |
|---|---|---|
height |
twips | Height (at-least) |
height.exact |
twips | Height (exact) |
header |
bool | Repeat as header |
c1, c2, c3, ... |
text | Set text of cell by 1-based index |
gridBefore |
int | Number of leading grid columns this row skips (w:gridBefore). Pairs with wBefore to indent the row's left edge (ragged left edge) |
wBefore |
width | Preferred width of the leading skipped span (w:wBefore). Unit-qualified: Ndxa, N%, auto, or nil
|
gridAfter |
int | Number of trailing grid columns this row skips (w:gridAfter). Pairs with wAfter to shorten the row's right edge |
wAfter |
width | Preferred width of the trailing skipped span (w:wAfter). Same unit-qualified form as wBefore
|
cnfStyle |
12-digit binary | Conditional-formatting bitmask (ST_Cnf @val) on the row (trPr). Same 12-region binary string as cell cnfStyle below |
cantSplit |
bool |
w:cantSplit — keep the row on one page (no break across pages). Add/Set/Get all support it; row-scoped (Word stores it per-row, not on the table) |
officecli set report.docx /body/tbl[1]/tr[1] --prop header=true --prop height=400
# Set cell text using c1/c2/c3 shorthand
officecli set report.docx /body/tbl[1]/tr[1] --prop c1="Name" --prop c2="Value"Path: /body/tbl[N]/tr[M]/tc[K]
| Property | Accepted Values | Description |
|---|---|---|
text |
text | Cell text |
font, size, bold, italic, color
|
various | Formatting (all runs) |
shd/shading
|
shading format | Cell background |
alignment |
left, center, right, justify
|
Horizontal alignment |
valign |
top, center, bottom
|
Vertical alignment |
width |
twips | Cell width |
vmerge |
restart, continue
|
Vertical merge |
gridSpan/colspan
|
integer | Columns spanned |
padding, padding.top/bottom/left/right
|
twips | Margins |
textDirection/textDir
|
btlr/vertical, tbrl/vertical-rl, lrtb/horizontal
|
Text direction |
nowrap |
bool | Disable text wrapping inside the cell. Add/Set/Get all support it (previously set-only; add-time support landed in v1.0.131) |
border.* |
border format | Cell borders (.all, .top, .bottom, .left, .right) |
border.tl2br |
border format | Diagonal border top-left to bottom-right |
border.tr2bl |
border format | Diagonal border top-right to bottom-left |
hideMark/hidemark
|
bool |
w:hideMark — ignore the end-of-cell mark when measuring row height for autofit (cell appears empty though it holds a paragraph mark) |
tcFitText/tcfittext
|
bool |
w:tcFitText — fit the cell's text to its width (the tcPr-level toggle; distinct from the run-level fitText) |
fitText/fittext
|
bool | Enable w:fitText on every run so text is squeezed to the cell width (set-only; apply after add) |
cnfStyle |
12-digit binary | Conditional-formatting bitmask (ST_Cnf @val) on the cell (tcPr). Each 0/1 flags one region in order: firstRow, lastRow, firstColumn, lastColumn, oddVBand, evenVBand, oddHBand, evenHBand, firstRowFirstColumn, firstRowLastColumn, lastRowFirstColumn, lastRowLastColumn. Short input is right-padded to 12. Not hex |
skipGridSync |
bool | Suppress the per-cell tblGrid synchronization that normally fires when width is set (set-only; used by dump→batch replay to preserve the source table's authoritative colWidths) |
Cell shading supports gradient format: shd=gradient;FF0000;0000FF;90 (type;color1;color2;angle)
# Style a header cell
officecli set report.docx /body/tbl[1]/tr[1]/tc[1] --prop text="Header" --prop bold=true --prop shd=4472C4 --prop color=FFFFFF --prop alignment=center
# Merge cells vertically
officecli set report.docx /body/tbl[1]/tr[1]/tc[1] --prop vmerge=restart
officecli set report.docx /body/tbl[1]/tr[2]/tc[1] --prop vmerge=continue
# Gradient cell shading
officecli set report.docx /body/tbl[1]/tr[1]/tc[1] --prop "shd=gradient;FF0000;0000FF;90"
# Diagonal cell borders
officecli set report.docx /body/tbl[1]/tr[1]/tc[1] --prop "border.tl2br=single;4;000000;0"
# Add image inside a table cell
officecli add report.docx /body/tbl[1]/tr[1]/tc[1] --type image --prop src=photo.jpgBased on OfficeCLI v1.0.131