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

PropertyUnits or values
columnWidthsPoints, in column order
rowFormatsOne entry per row; row heights use twips
Cell formatshading, borders, verticalAlignment, and margins
Cell marginsTwips, 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.

Anchored table edits and formatting

Next Images and shapes