PowerPoint.TableAddOptions interface

表示添加表时的可用选项。

注解

API 集:PowerPointApi 1.8

使用方

示例

// 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();
});

属性

columns

如果提供,则指定表中每列的属性。 数组长度必须等于表中的列数。 为应使用默认格式的列指定空对象。

height

指定表的高度(以磅为单位)。 未提供此参数时,将使用默认值。 使用负值设置时引发 InvalidArgument 异常。

注意:如果表格高度不能被行数整除,PowerPoint 会将其设置为尽可能接近的值。 例如,3 行的高度为 400 可能会导致实际高度为 399.9999。

left

指定从表格左侧到幻灯片左侧的距离(以磅为单位)。 如果未提供此参数,表格将水平居中。

mergedAreas

如果指定,则表示多个单元格显示为单个单元格的矩形区域。

rows

如果提供,则指定表中每一行的属性。 数组长度必须等于表中的行数。 为应使用默认格式的行指定空对象。

specificCellProperties

如果提供,则指定表中每个单元格的属性。

这应该是一个与表具有相同行数和列数的 2D 数组。 如果单元格不需要特定格式,请为该单元格指定空对象。 只有合并的 are 的左上角单元格可以指定属性,这些属性将应用于整个合并区域。 对于合并区域中的其他单元格,应提供一个空对象。

style

指定表示表格样式的值。

top

指定从表格顶部边缘到幻灯片顶部边缘的距离(以磅为单位)。 未提供此参数时,将使用默认值。

uniformCellProperties

指定统一应用于所有表格单元格的格式。

若要对单个单元格应用特定格式,请使用specificCellProperties

如果 uniformCellProperties 和 specificCellProperties 均未定义,则将使用默认格式设置,并应用默认表格样式。 表格的外观与用户通过 PowerPoint UI 添加表格时的外观相同。

若要为表格提供纯色外观,请将此属性设置为空对象,并且不要指定 specificCellProperties

values

如果提供,则指定表的值。

当表包含合并单元格区域时,只有每个合并区域的左上角单元格可以具有非空字符串值。 合并区域中的其他单元格必须为空字符串。

width

指定表的宽度(以磅为单位)。 未提供此参数时,将使用默认值。 使用负值设置时引发 InvalidArgument 异常。

注意:如果表格宽度不能被列数整除,PowerPoint 会将其设置为最接近的可能值。 例如,3 列的宽度为 400 可能会导致实际宽度为 399.9999。

属性详细信息

columns

如果提供,则指定表中每列的属性。 数组长度必须等于表中的列数。 为应使用默认格式的列指定空对象。

columns?: PowerPoint.TableColumnProperties[];

属性值

注解

API 集:PowerPointApi 1.8

示例

// 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

指定表的高度(以磅为单位)。 未提供此参数时,将使用默认值。 使用负值设置时引发 InvalidArgument 异常。

注意:如果表格高度不能被行数整除,PowerPoint 会将其设置为尽可能接近的值。 例如,3 行的高度为 400 可能会导致实际高度为 399.9999。

height?: number | undefined;

属性值

number | undefined

注解

API 集:PowerPointApi 1.8

示例

// 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

指定从表格左侧到幻灯片左侧的距离(以磅为单位)。 如果未提供此参数,表格将水平居中。

left?: number | undefined;

属性值

number | undefined

注解

API 集:PowerPointApi 1.8

mergedAreas

如果指定,则表示多个单元格显示为单个单元格的矩形区域。

mergedAreas?: PowerPoint.TableMergedAreaProperties[];

属性值

注解

API 集:PowerPointApi 1.8

示例

// 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

如果提供,则指定表中每一行的属性。 数组长度必须等于表中的行数。 为应使用默认格式的行指定空对象。

rows?: PowerPoint.TableRowProperties[];

属性值

注解

API 集:PowerPointApi 1.8

示例

// 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

如果提供,则指定表中每个单元格的属性。

这应该是一个与表具有相同行数和列数的 2D 数组。 如果单元格不需要特定格式,请为该单元格指定空对象。 只有合并的 are 的左上角单元格可以指定属性,这些属性将应用于整个合并区域。 对于合并区域中的其他单元格,应提供一个空对象。

specificCellProperties?: PowerPoint.TableCellProperties[][];

属性值

注解

API 集:PowerPointApi 1.8

示例

// 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();
});

style

指定表示表格样式的值。

style?: PowerPoint.TableStyle | "NoStyleNoGrid" | "ThemedStyle1Accent1" | "ThemedStyle1Accent2" | "ThemedStyle1Accent3" | "ThemedStyle1Accent4" | "ThemedStyle1Accent5" | "ThemedStyle1Accent6" | "NoStyleTableGrid" | "ThemedStyle2Accent1" | "ThemedStyle2Accent2" | "ThemedStyle2Accent3" | "ThemedStyle2Accent4" | "ThemedStyle2Accent5" | "ThemedStyle2Accent6" | "LightStyle1" | "LightStyle1Accent1" | "LightStyle1Accent2" | "LightStyle1Accent3" | "LightStyle1Accent4" | "LightStyle1Accent5" | "LightStyle1Accent6" | "LightStyle2" | "LightStyle2Accent1" | "LightStyle2Accent2" | "LightStyle2Accent3" | "LightStyle2Accent4" | "LightStyle2Accent5" | "LightStyle2Accent6" | "LightStyle3" | "LightStyle3Accent1" | "LightStyle3Accent2" | "LightStyle3Accent3" | "LightStyle3Accent4" | "LightStyle3Accent5" | "LightStyle3Accent6" | "MediumStyle1" | "MediumStyle1Accent1" | "MediumStyle1Accent2" | "MediumStyle1Accent3" | "MediumStyle1Accent4" | "MediumStyle1Accent5" | "MediumStyle1Accent6" | "MediumStyle2" | "MediumStyle2Accent1" | "MediumStyle2Accent2" | "MediumStyle2Accent3" | "MediumStyle2Accent4" | "MediumStyle2Accent5" | "MediumStyle2Accent6" | "MediumStyle3" | "MediumStyle3Accent1" | "MediumStyle3Accent2" | "MediumStyle3Accent3" | "MediumStyle3Accent4" | "MediumStyle3Accent5" | "MediumStyle3Accent6" | "MediumStyle4" | "MediumStyle4Accent1" | "MediumStyle4Accent2" | "MediumStyle4Accent3" | "MediumStyle4Accent4" | "MediumStyle4Accent5" | "MediumStyle4Accent6" | "DarkStyle1" | "DarkStyle1Accent1" | "DarkStyle1Accent2" | "DarkStyle1Accent3" | "DarkStyle1Accent4" | "DarkStyle1Accent5" | "DarkStyle1Accent6" | "DarkStyle2" | "DarkStyle2Accent1" | "DarkStyle2Accent2" | "DarkStyle2Accent3";

属性值

PowerPoint.TableStyle | "NoStyleNoGrid" | "ThemedStyle1Accent1" | "ThemedStyle1Accent2" | "ThemedStyle1Accent3" | "ThemedStyle1Accent4" | "ThemedStyle1Accent5" | "ThemedStyle1Accent6" | "NoStyleTableGrid" | "ThemedStyle2Accent1" | "ThemedStyle2Accent2" | "ThemedStyle2Accent3" | "ThemedStyle2Accent4" | "ThemedStyle2Accent5" | "ThemedStyle2Accent6" | "LightStyle1" | "LightStyle1Accent1" | "LightStyle1Accent2" | "LightStyle1Accent3" | "LightStyle1Accent4" | "LightStyle1Accent5" | "LightStyle1Accent6" | "LightStyle2" | "LightStyle2Accent1" | "LightStyle2Accent2" | "LightStyle2Accent3" | "LightStyle2Accent4" | "LightStyle2Accent5" | "LightStyle2Accent6" | "LightStyle3" | "LightStyle3Accent1" | "LightStyle3Accent2" | "LightStyle3Accent3" | "LightStyle3Accent4" | "LightStyle3Accent5" | "LightStyle3Accent6" | "MediumStyle1" | "MediumStyle1Accent1" | "MediumStyle1Accent2" | "MediumStyle1Accent3" | "MediumStyle1Accent4" | "MediumStyle1Accent5" | "MediumStyle1Accent6" | "MediumStyle2" | "MediumStyle2Accent1" | "MediumStyle2Accent2" | "MediumStyle2Accent3" | "MediumStyle2Accent4" | "MediumStyle2Accent5" | "MediumStyle2Accent6" | "MediumStyle3" | "MediumStyle3Accent1" | "MediumStyle3Accent2" | "MediumStyle3Accent3" | "MediumStyle3Accent4" | "MediumStyle3Accent5" | "MediumStyle3Accent6" | "MediumStyle4" | "MediumStyle4Accent1" | "MediumStyle4Accent2" | "MediumStyle4Accent3" | "MediumStyle4Accent4" | "MediumStyle4Accent5" | "MediumStyle4Accent6" | "DarkStyle1" | "DarkStyle1Accent1" | "DarkStyle1Accent2" | "DarkStyle1Accent3" | "DarkStyle1Accent4" | "DarkStyle1Accent5" | "DarkStyle1Accent6" | "DarkStyle2" | "DarkStyle2Accent1" | "DarkStyle2Accent2" | "DarkStyle2Accent3"

注解

API 集:PowerPointApi 1.9

top

指定从表格顶部边缘到幻灯片顶部边缘的距离(以磅为单位)。 未提供此参数时,将使用默认值。

top?: number | undefined;

属性值

number | undefined

注解

API 集:PowerPointApi 1.8

uniformCellProperties

指定统一应用于所有表格单元格的格式。

若要对单个单元格应用特定格式,请使用specificCellProperties

如果 uniformCellProperties 和 specificCellProperties 均未定义,则将使用默认格式设置,并应用默认表格样式。 表格的外观与用户通过 PowerPoint UI 添加表格时的外观相同。

若要为表格提供纯色外观,请将此属性设置为空对象,并且不要指定 specificCellProperties

uniformCellProperties?: PowerPoint.TableCellProperties;

属性值

注解

API 集:PowerPointApi 1.8

示例

// 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

如果提供,则指定表的值。

当表包含合并单元格区域时,只有每个合并区域的左上角单元格可以具有非空字符串值。 合并区域中的其他单元格必须为空字符串。

values?: string[][];

属性值

string[][]

注解

API 集:PowerPointApi 1.8

示例

// 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

指定表的宽度(以磅为单位)。 未提供此参数时,将使用默认值。 使用负值设置时引发 InvalidArgument 异常。

注意:如果表格宽度不能被列数整除,PowerPoint 会将其设置为最接近的可能值。 例如,3 列的宽度为 400 可能会导致实际宽度为 399.9999。

width?: number | undefined;

属性值

number | undefined

注解

API 集:PowerPointApi 1.8

示例

// 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();
});