Edit

Share via


PowerPoint.TableCellProperties interface

Represents the table cell properties to update.

Remarks

[ API set: PowerPointApi 1.8 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml

// Specifies the font formatting and fill colors of the cells in a table.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;

  // Add a table, specifying font formatting and fill colors
  shapes.addTable(3, 4, {
    values: [
      ["A", "BB", "CCC", "DDDD"],
      ["E", "FF", "GGG", "HHHH"],
      ["1", "12", "123", "1234"]
    ],
    specificCellProperties: [
      [
        { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } },
        { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } },
        { fill: { color: "red" }, font: { color: "yellow", italic: true } },
        { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } }
      ],
      [
        { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } },
        { fill: { color: "red" }, font: { color: "yellow", subscript: true } },
        { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } },
        { fill: { color: "red" }, font: { color: "yellow" } }
      ],
      [
        { fill: { color: "red" }, font: { color: "#b0bf1a" } },
        { fill: { color: "#9966cc" }, font: { color: "yellow" } },
        { fill: { color: "#b0bf1a" }, font: { color: "yellow" } },
        { fill: { color: "red" }, font: { color: "#fbceb1" } }
      ]
    ]
  });
  await context.sync();
});

Properties

borders

Specifies the border formatting of the table cell.

fill

Specifies the fill formatting of the table cell.

font

Specifies the font formatting of the table cell.

horizontalAlignment

Represents the horizontal alignment of the table cell.

indentLevel

Represents the indent level of the text in the table cell.

margins

Specifies the margin settings in the table cell.

text

Specifies the text content of the table cell.

If a portion of the text requires different formatting, use the textRuns property instead.

textRuns

Specifies the contents of the table cell as an array of objects. Each TextRun object represents a sequence of one or more characters that share the same font attributes.

verticalAlignment

Represents the vertical alignment of the table cell.

Property Details

borders

Specifies the border formatting of the table cell.

borders?: PowerPoint.TableCellBorders;

Property Value

Remarks

[ API set: PowerPointApi 1.8 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml

// Specifies a table's borders.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;

  // Add a table, specifying border styles
  shapes.addTable(3, 4, {
    values: [
      ["A", "BB", "CCC", "DDDD"],
      ["E", "FF", "GGG", "HHHH"],
      ["1", "12", "123", "1234"]
    ],
    uniformCellProperties: {
      borders: {
        left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 },
        right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 },
        top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 },
        bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }
      }
    }
  });
  await context.sync();
});

fill

Specifies the fill formatting of the table cell.

fill?: PowerPoint.FillProperties;

Property Value

Remarks

[ API set: PowerPointApi 1.8 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml

// Specifies the font formatting and fill colors of the cells in a table.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;

  // Add a table, specifying font formatting and fill colors
  shapes.addTable(3, 4, {
    values: [
      ["A", "BB", "CCC", "DDDD"],
      ["E", "FF", "GGG", "HHHH"],
      ["1", "12", "123", "1234"]
    ],
    specificCellProperties: [
      [
        { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } },
        { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } },
        { fill: { color: "red" }, font: { color: "yellow", italic: true } },
        { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } }
      ],
      [
        { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } },
        { fill: { color: "red" }, font: { color: "yellow", subscript: true } },
        { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } },
        { fill: { color: "red" }, font: { color: "yellow" } }
      ],
      [
        { fill: { color: "red" }, font: { color: "#b0bf1a" } },
        { fill: { color: "#9966cc" }, font: { color: "yellow" } },
        { fill: { color: "#b0bf1a" }, font: { color: "yellow" } },
        { fill: { color: "red" }, font: { color: "#fbceb1" } }
      ]
    ]
  });
  await context.sync();
});

font

Specifies the font formatting of the table cell.

font?: PowerPoint.FontProperties;

Property Value

Remarks

[ API set: PowerPointApi 1.8 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml

// Specifies the font formatting and fill colors of the cells in a table.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;

  // Add a table, specifying font formatting and fill colors
  shapes.addTable(3, 4, {
    values: [
      ["A", "BB", "CCC", "DDDD"],
      ["E", "FF", "GGG", "HHHH"],
      ["1", "12", "123", "1234"]
    ],
    specificCellProperties: [
      [
        { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } },
        { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } },
        { fill: { color: "red" }, font: { color: "yellow", italic: true } },
        { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } }
      ],
      [
        { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } },
        { fill: { color: "red" }, font: { color: "yellow", subscript: true } },
        { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } },
        { fill: { color: "red" }, font: { color: "yellow" } }
      ],
      [
        { fill: { color: "red" }, font: { color: "#b0bf1a" } },
        { fill: { color: "#9966cc" }, font: { color: "yellow" } },
        { fill: { color: "#b0bf1a" }, font: { color: "yellow" } },
        { fill: { color: "red" }, font: { color: "#fbceb1" } }
      ]
    ]
  });
  await context.sync();
});

horizontalAlignment

Represents the horizontal alignment of the table cell.

horizontalAlignment?: PowerPoint.ParagraphHorizontalAlignment | "Left" | "Center" | "Right" | "Justify" | "JustifyLow" | "Distributed" | "ThaiDistributed" | undefined;

Property Value

PowerPoint.ParagraphHorizontalAlignment | "Left" | "Center" | "Right" | "Justify" | "JustifyLow" | "Distributed" | "ThaiDistributed" | undefined

Remarks

[ API set: PowerPointApi 1.8 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml

// Specifies the horizontal and vertical alignments of the cells in a table.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;

  // Add a table, specifying horizontal and vertical alignment.
  shapes.addTable(3, 4, {
    values: [
      ["A", "BB", "CCC", "DDDD"],
      ["E", "FF", "GGG", "HHHH"],
      ["1", "12", "123", "1234"]
    ],
    uniformCellProperties: {
      horizontalAlignment: PowerPoint.ParagraphHorizontalAlignment.justify,
      verticalAlignment: PowerPoint.TextVerticalAlignment.middle
    }
  });
  await context.sync();
});

indentLevel

Represents the indent level of the text in the table cell.

indentLevel?: number | undefined;

Property Value

number | undefined

Remarks

[ API set: PowerPointApi 1.8 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml

// Specifying the indents for a table.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;

  // Add a table, specifying the indent level for cells.
  shapes.addTable(3, 4, {
    values: [
      ["A", "BB", "CCC", "DDDD"],
      ["E", "FF", "GGG", "HHHH"],
      ["1", "12", "123", "1234"]
    ],
    specificCellProperties: [
      [{ indentLevel: 0 }, { indentLevel: 1 }, { indentLevel: 2 }, { indentLevel: 3 }],
      [{ indentLevel: 0 }, { indentLevel: 1 }, { indentLevel: 2 }, { indentLevel: 3 }],
      [{ indentLevel: 0 }, { indentLevel: 1 }, { indentLevel: 2 }, { indentLevel: 3 }]
    ]
  });
  await context.sync();
});

margins

Specifies the margin settings in the table cell.

margins?: PowerPoint.TableCellMargins;

Property Value

Remarks

[ API set: PowerPointApi 1.8 ]

text

Specifies the text content of the table cell.

If a portion of the text requires different formatting, use the textRuns property instead.

text?: string;

Property Value

string

Remarks

[ API set: PowerPointApi 1.8 ]

textRuns

Specifies the contents of the table cell as an array of objects. Each TextRun object represents a sequence of one or more characters that share the same font attributes.

textRuns?: PowerPoint.TextRun[];

Property Value

Remarks

[ API set: PowerPointApi 1.8 ]

verticalAlignment

Represents the vertical alignment of the table cell.

verticalAlignment?: PowerPoint.TextVerticalAlignment | "Top" | "Middle" | "Bottom" | "TopCentered" | "MiddleCentered" | "BottomCentered" | undefined;

Property Value

PowerPoint.TextVerticalAlignment | "Top" | "Middle" | "Bottom" | "TopCentered" | "MiddleCentered" | "BottomCentered" | undefined

Remarks

[ API set: PowerPointApi 1.8 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml

// Specifies the horizontal and vertical alignments of the cells in a table.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;

  // Add a table, specifying horizontal and vertical alignment.
  shapes.addTable(3, 4, {
    values: [
      ["A", "BB", "CCC", "DDDD"],
      ["E", "FF", "GGG", "HHHH"],
      ["1", "12", "123", "1234"]
    ],
    uniformCellProperties: {
      horizontalAlignment: PowerPoint.ParagraphHorizontalAlignment.justify,
      verticalAlignment: PowerPoint.TextVerticalAlignment.middle
    }
  });
  await context.sync();
});