Skip to content

word table set

zmworm edited this page Apr 29, 2026 · 52 revisions

Word: Table - set

Modify table, row, and cell properties.


Table

Path: /body/tbl[N]

Properties

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)

Examples

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"

Table Row

Path: /body/tbl[N]/tr[M]

Properties

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

Examples

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"

Table Cell

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

Properties

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 No wrap
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

Cell shading supports gradient format: shd=gradient;FF0000;0000FF;90 (type;color1;color2;angle)

Examples

# 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.jpg

Based on OfficeCLI v1.0.64

Clone this wiki locally