Skip to content

Tables ​

Create data tables with cell-level formatting.

Basic Table ​

typescript
slide.addTable([
  [{ text: 'Name' }, { text: 'Score' }],
  [{ text: 'Alice' }, { text: '95' }],
  [{ text: 'Bob' }, { text: '87' }],
], { x: 1, y: 1, w: 6, h: 3 });

Styled Headers ​

typescript
slide.addTable([
  [
    { text: 'Feature', options: { bold: true, fill: '4472C4', color: 'FFFFFF' } },
    { text: 'Status', options: { bold: true, fill: '4472C4', color: 'FFFFFF' } },
  ],
  [{ text: 'Text' }, { text: 'Done' }],
  [{ text: 'Charts' }, { text: 'Done' }],
], { x: 1, y: 1, w: 8, h: 4, border: { color: 'CCCCCC', width: 1 } });
Styled table output
Styled table output

Cell Merging ​

Use colSpan and rowSpan to merge cells:

typescript
slide.addTable([
  [
    { text: 'Merged Header', options: { colSpan: 3, bold: true, fill: '003366', color: 'FFFFFF', align: 'center' } },
    { text: '' },
    { text: '' },
  ],
  [{ text: 'A' }, { text: 'B' }, { text: 'C' }],
], { x: 1, y: 1, w: 8, h: 2 });
Cell merging output
Cell merging output

Per-Cell Borders ​

typescript
slide.addTable([
  [{
    text: 'Custom borders',
    options: {
      borderBottom: { color: 'FF0000', width: 2 },
      borderRight: { color: '0000FF', width: 1 },
    },
  }],
], { x: 1, y: 1, w: 4, h: 1 });

Banded Rows ​

typescript
slide.addTable(rows, {
  x: 1, y: 1, w: 8, h: 5,
  bandRow: true,
  bandRowColors: ['F0F0F0', 'FFFFFF'],
  firstRow: true,
});
FlagDescription
firstRowApply special formatting to the first row
lastRowApply special formatting to the last row
firstColApply special formatting to the first column
lastColApply special formatting to the last column
bandRowAlternate row shading
bandColAlternate column shading

Cell Options ​

Each cell can have:

OptionTypeDescription
textstringCell content
options.boldbooleanBold text
options.italicbooleanItalic text
options.fontSizenumberFont size
options.colorColorText color
options.fillFillCell background
options.alignstringText alignment
options.verticalAlignstring'top', 'middle', 'bottom', 'distributed'
options.colSpannumberColumns to span
options.rowSpannumberRows to span
options.marginobjectCell padding { top, right, bottom, left }

See TableCell for the full reference.

Table Options ​

OptionTypeDescription
x, ynumberPosition in inches
w, hnumberSize in inches
colWidthsnumber[]Column widths in inches
rowHeightsnumber[]Row heights in inches
borderTableBorderOptionsTable-wide border settings
fillFillDefault cell background
bandRowbooleanAlternate row shading
bandRowColors[Color, Color]Alternating row colors

See TableOptions for the full reference.

Released under the MIT License.