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使用负值设置时引发异常。

left

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

mergedAreas

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

rows

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

specificCellProperties

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

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

style

指定表示表格样式的值。

top

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

uniformCellProperties

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

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

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

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

values

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

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

width

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

属性详细信息

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使用负值设置时引发异常。

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

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

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

指定表示表格样式的值。

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 BETA (仅预览版) ]

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使用负值设置时引发异常。

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