Tables
Author nested tables and control cell formatting and geometry.
Create a table
Table cells contain WordContentBlock arrays, including nested tables. Pass the complete block tree to NativeWordDocument.update or createWordArtifact.
TypeScript
import { NativeWordDocument } from '@tumblerjs/word';
const model = new NativeWordDocument();
model.update([{
kind: 'table', id: 'summary', columnWidths: [180, 270],
rowFormats: [{ heightRule: 'atLeast', heightTwips: 480 }],
rows: [[
{ format: { shading: '#EEEEEE', verticalAlignment: 'center' },
blocks: [{ kind: 'paragraph', runs: [{ text: 'Status' }] }] },
{ blocks: [{ kind: 'paragraph', runs: [{ text: 'Draft' }] }] },
]],
}]);
const bytes = model.artifact().bytes();Set dimensions and cell formatting
| Property | Units or values |
|---|---|
| columnWidths | Points, in column order |
| rowFormats | One entry per row; row heights use twips |
| Cell format | shading, borders, verticalAlignment, and margins |
| Cell margins | Twips, 20 per point |
Imported tables and pagination
Imported spans and vertical merges retain their source identities. Rows can continue across pages at cell line boundaries, and leading header rows repeat.
Direct borders and solid fills are supported; conditional table styles, patterned fills, and theme-based table colours are not fully resolved.