PPTX

Tables

Create tables with merged cells, custom styling, and formatted content

Use TableFrame to add structured tabular data to slides.

Basic Table

import { Slide, TableFrame, Paragraph, TextRun } from "@office-open/pptx";

new Slide({
    children: [
        new TableFrame({
            x: 1,
            y: 1,
            width: 8,
            height: 3,
            rows: [
                {
                    cells: [
                        { text: "Name", options: { bold: true } },
                        { text: "Role", options: { bold: true } },
                        { text: "Department", options: { bold: true } },
                    ],
                    header: true,
                },
                { cells: [{ text: "Alice" }, { text: "Engineer" }, { text: "Dev" }] },
                { cells: [{ text: "Bob" }, { text: "Designer" }, { text: "UX" }] },
                { cells: [{ text: "Carol" }, { text: "Manager" }, { text: "Ops" }] },
            ],
        }),
    ],
});

Cell Formatting

Each cell supports text formatting options:

new TableFrame({
    x: 1,
    y: 1,
    width: 8,
    height: 3,
    rows: [
        {
            cells: [
                {
                    text: "Header",
                    options: { bold: true, fontSize: 14, color: "FFFFFF" },
                    fill: { type: "solid", color: "2E74B5" },
                    align: "center",
                    valign: "middle",
                },
            ],
            header: true,
        },
        {
            cells: [
                {
                    text: "Data cell",
                    options: { fontSize: 12 },
                    fill: { type: "solid", color: "F2F2F2" },
                },
            ],
        },
    ],
});

Rich Cell Content

Cells can contain full Paragraph objects:

import { Paragraph, TextRun } from "@office-open/pptx";

{
  cells: [
    {
      paragraphs: [
        new Paragraph({
          children: [
            new TextRun({ text: "Bold title", bold: true, fontSize: 14 }),
          ],
        }),
        new Paragraph({
          children: [
            new TextRun({ text: "Description text", fontSize: 11, color: "666666" }),
          ],
        }),
      ],
    },
  ],
}

Merged Cells

Merge cells horizontally or vertically using rowSpan and colSpan:

new TableFrame({
    x: 1,
    y: 1,
    width: 8,
    height: 4,
    rows: [
        {
            cells: [
                { text: "Category", options: { bold: true }, rowSpan: 2 },
                { text: "Q1", options: { bold: true } },
                { text: "Q2", options: { bold: true } },
            ],
        },
        {
            cells: [
                // First cell is merged from the row above
                { text: "100" },
                { text: "120" },
            ],
        },
        {
            cells: [
                { text: "Products", options: { bold: true }, rowSpan: 2 },
                { text: "200" },
                { text: "250" },
            ],
        },
        {
            cells: [{ text: "210" }, { text: "270" }],
        },
    ],
});

Column Widths

Control column widths explicitly:

new TableFrame({
    x: 1,
    y: 1,
    width: 8,
    colWidths: [2, 3, 3], // Widths in inches for each column
    rows: [
        { cells: [{ text: "ID" }, { text: "Name" }, { text: "Email" }] },
        { cells: [{ text: "1" }, { text: "Alice" }, { text: "alice@example.com" }] },
    ],
});

Borders

Customize cell borders:

{
  text: "Cell with border",
  borders: {
    top: { style: "single", size: 2, color: "2E74B5" },
    bottom: { style: "single", size: 2, color: "2E74B5" },
    left: { style: "single", size: 2, color: "2E74B5" },
    right: { style: "single", size: 2, color: "2E74B5" },
  },
}
Copyright © 2026