PowerPoint.TableAddOptions interface
Represents the available options when adding a table.
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 width and height of a table.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
// Add a table, specifying the width and height.
shapes.addTable(3, 4, {
width: 600,
height: 400
});
await context.sync();
});
Properties
columns | If provided, specifies properties for each column in the table. The array length must be equal to the number of columns in the table. Specify an empty object for columns that should use the default formatting. |
height | Specifies the height, in points, of the table. A default value is used when this parameter isn't provided. Throws an |
left | Specifies the distance, in points, from the left side of the table to the left side of the slide. The table is centered horizontally when this parameter isn't provided. |
merged |
If specified, represents an rectangular area where multiple cells appear as a single cell. |
rows | If provided, specifies properties for each row in the table. The array length must be equal to the number of rows in the table. Specify an empty object for rows that should use the default formatting. |
specific |
If provided, specifies properties for each cell in the table. This should be an 2D array with the same number of rows and columns as the table. If a cell doesn't require specific formatting, specify an empty object for that cell. Only the top left cell of a merged are can have properties specified, which will be applied to the entire merged area. For the other cells in the merged area, an empty object should be provided. |
top | Specifies the distance, in points, from the top edge of the table to the top edge of the slide. A default value is used when this parameter isn't provided. |
uniform |
Specifies the formatting which applies uniformly to all of the table cells. To apply specific formatting to individual cells, use specificCellProperties. If both uniformCellProperties and specificCellProperties are undefined, the default formatting will be used, and the default table style will be applied. The table will have the same appearance as when the user adds a table through the PowerPoint UI. To provide a plain appearance for the table, set this property to an empty object and don't specify specificCellProperties. |
values | If provided, specifies the values for the table. When the table contains areas of merged cells, only the top left cell of each merged area can have a non-empty string value. The other cells in the merged area must be an empty string. |
width | Specifies the width, in points, of the table. A default value is used when this parameter isn't provided. Throws an |
Property Details
columns
If provided, specifies properties for each column in the table. The array length must be equal to the number of columns in the table. Specify an empty object for columns that should use the default formatting.
columns?: PowerPoint.TableColumnProperties[];
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 column widths and row heights of a table.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
// Add a table, specifying column widths and row heights
shapes.addTable(3, 4, {
columns: [{ columnWidth: 100 }, { columnWidth: 200 }, { columnWidth: 100 }, { columnWidth: 200 }],
rows: [{ rowHeight: 60 }, { rowHeight: 120 }, { rowHeight: 180 }]
});
await context.sync();
});
height
Specifies the height, in points, of the table. A default value is used when this parameter isn't provided. Throws an InvalidArgument
exception when set with a negative value.
height?: 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
// Specifies the width and height of a table.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
// Add a table, specifying the width and height.
shapes.addTable(3, 4, {
width: 600,
height: 400
});
await context.sync();
});
left
Specifies the distance, in points, from the left side of the table to the left side of the slide. The table is centered horizontally when this parameter isn't provided.
left?: number | undefined;
Property Value
number | undefined
Remarks
mergedAreas
If specified, represents an rectangular area where multiple cells appear as a single cell.
mergedAreas?: PowerPoint.TableMergedAreaProperties[];
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 merge areas of a table.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
// Add a table, specifying one 2x2 merged area.
shapes.addTable(3, 4, {
values: [
["A", "BB", "CCC", "DDDD"],
["E", "FF", "", "HHHH"],
["1", "", "", "1234"]
],
mergedAreas: [{ rowIndex: 1, columnIndex: 1, rowCount: 2, columnCount: 2 }]
});
await context.sync();
});
rows
If provided, specifies properties for each row in the table. The array length must be equal to the number of rows in the table. Specify an empty object for rows that should use the default formatting.
rows?: PowerPoint.TableRowProperties[];
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 column widths and row heights of a table.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
// Add a table, specifying column widths and row heights
shapes.addTable(3, 4, {
columns: [{ columnWidth: 100 }, { columnWidth: 200 }, { columnWidth: 100 }, { columnWidth: 200 }],
rows: [{ rowHeight: 60 }, { rowHeight: 120 }, { rowHeight: 180 }]
});
await context.sync();
});
specificCellProperties
If provided, specifies properties for each cell in the table.
This should be an 2D array with the same number of rows and columns as the table. If a cell doesn't require specific formatting, specify an empty object for that cell. Only the top left cell of a merged are can have properties specified, which will be applied to the entire merged area. For the other cells in the merged area, an empty object should be provided.
specificCellProperties?: PowerPoint.TableCellProperties[][];
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();
});
top
Specifies the distance, in points, from the top edge of the table to the top edge of the slide. A default value is used when this parameter isn't provided.
top?: number | undefined;
Property Value
number | undefined
Remarks
uniformCellProperties
Specifies the formatting which applies uniformly to all of the table cells.
To apply specific formatting to individual cells, use specificCellProperties.
If both uniformCellProperties and specificCellProperties are undefined, the default formatting will be used, and the default table style will be applied. The table will have the same appearance as when the user adds a table through the PowerPoint UI.
To provide a plain appearance for the table, set this property to an empty object and don't specify specificCellProperties.
uniformCellProperties?: PowerPoint.TableCellProperties;
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();
});
values
If provided, specifies the values for the table.
When the table contains areas of merged cells, only the top left cell of each merged area can have a non-empty string value. The other cells in the merged area must be an empty string.
values?: string[][];
Property Value
string[][]
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 values.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
// Add a table, specifying cell values.
const shape = shapes.addTable(3, 4, {
values: [
["A", "BB", "CCC", "DDDD"],
["E", "FF", "GGG", "HHHH"],
["1", "12", "123", "1234"]
]
});
await context.sync();
});
width
Specifies the width, in points, of the table. A default value is used when this parameter isn't provided. Throws an InvalidArgument
exception when set with a negative value.
width?: 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
// Specifies the width and height of a table.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
// Add a table, specifying the width and height.
shapes.addTable(3, 4, {
width: 600,
height: 400
});
await context.sync();
});