Word.Table class

表示 Word 文档中的表格。

扩展

注解

API 集:WordApi 1.3

使用方

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/table-cell-access.yaml

await Word.run(async (context) => {
  // Use a two-dimensional array to hold the initial table values.
  const data = [
    ["Tokyo", "Beijing", "Seattle"],
    ["Apple", "Orange", "Pineapple"]
  ];
  const table: Word.Table = context.document.body.insertTable(2, 3, "Start", data);
  table.styleBuiltIn = Word.BuiltInStyleName.gridTable5Dark_Accent2;
  table.styleFirstColumn = false;

  await context.sync();
});

属性

alignment

指定表与页列的对齐方式。 值可以是 left、 centered或 right。

columns

返回 TableColumnCollection 表示表中列的对象。

context

与对象关联的请求上下文。 这将加载项的进程连接到 Office 主机应用程序的进程。

description

指定表的说明。

endnotes

获取表中尾注的集合。

fields

获取表中对象的 Field 集合。

font

获取字体。 使用此关系可获取并设置字体名称、大小、颜色和其他属性。

footnotes

获取表中脚注的集合。

headerRowCount

指定标题行数。

horizontalAlignment

指定表中每个单元格的水平对齐方式。 值可以是 left、centered 、right 或 。justified

isUniform

指明所有表行是否一致。

nestingLevel

获取 table 的嵌套级别。 顶级 table 的级别为 1。

parentBody

获取 table 的父正文。

parentContentControl

获取包含 table 的 contentControl。 如果没有父内容控件,则引发 ItemNotFound 错误。

parentContentControlOrNullObject

获取包含 table 的 contentControl。 如果没有父内容控件,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

parentTable

获取包含此 table 的 table。 如果表中未包含,则引发 ItemNotFound 错误。

parentTableCell

获取包含此 table 的 tableCell。 如果表单元格中未包含错误,则引发 ItemNotFound 错误。

parentTableCellOrNullObject

获取包含此 table 的 tableCell。 如果它未包含在表单元格中,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

parentTableOrNullObject

获取包含此 table 的 table。 如果它未包含在表中,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

rowCount

获取表格中的行数。

rows

获取所有表格行。

shading

返回 ShadingUniversal 表示表格底纹的对象。

shadingColor

指定底纹颜色。 按“#RRGGBB”格式或使用颜色名称指定颜色。

style

指定表格的样式名称。 请对自定义样式和本地化样式名称使用此属性。 若要使用可以在区域设置之间移植的嵌入样式,请参阅“styleBuiltIn”属性。

styleBandedColumns

指定表是否具有带状列。

styleBandedRows

指定表是否具有带状行。

styleBuiltIn

指定表的内置样式名称。 请对可以在区域设置之间移植的嵌入样式使用此属性。 若要使用自定义样式或本地化样式名称,请参阅“style”属性。

styleFirstColumn

指定表的第一列是否具有特殊样式。

styleLastColumn

指定表的最后一列是否具有特殊样式。

styleTotalRow

指定表是否具有具有特殊样式 (最后) 行的总和。

tables

获取嵌套一级的子 table。

title

指定表的标题。

values

将表中的文本值指定为 2D JavaScript 数组。

verticalAlignment

指定表格中每个单元格的垂直对齐方式。 值可以是 top、 center或 bottom。

width

指定表的宽度(以磅为单位)。

方法

addColumns(insertLocation, columnCount, values)

使用第一个或最后一个现有列作为模板,将列添加到 table 的开头或结尾。 此方法适用于一致的 table。 字符串值(若指定)是在新插入的行中进行设置。

addRows(insertLocation, rowCount, values)

使用第一个或最后一个现有行作为模板,将行添加到 table 的开头或结尾。 字符串值(若指定)是在新插入的行中进行设置。

applyStyleDirectFormatting(styleName)

应用指定的样式,但保留用户直接应用的所有格式。

autoFitBehavior(behavior)

确定 Microsoft Word 如何使用自动调整功能来调整表格的大小。

autoFitBehavior(behavior)

确定 Microsoft Word 如何使用自动调整功能来调整表格的大小。

autoFitWindow()

自动调整表列,以适应窗口的宽度。

autoFormat(options)

将预定义外观应用于表格。

clear()

清除表内容。

convertToText(options)

将表格转换为文本。

delete()

删除整个表格。

deleteColumns(columnIndex, columnCount)

删除特定的列。 此方法适用于一致的 table。

deleteRows(rowIndex, rowCount)

删除特定的行。

distributeColumns()

将列设置为等宽。 此方法适用于一致的 table。

getBorder(borderLocation)

获取指定边框的边框样式。

getBorder(borderLocation)

获取指定边框的边框样式。

getCell(rowIndex, cellIndex)

获取指定行和列处的表单元格。 如果指定的表单元格不存在,则引发 ItemNotFound 错误。

getCellOrNullObject(rowIndex, cellIndex)

获取指定行和列处的表单元格。 如果指定的表单元格不存在,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

getCellPadding(cellPaddingLocation)

获取单元格填充(以磅为单位)。

getCellPadding(cellPaddingLocation)

获取单元格填充(以磅为单位)。

getNext()

获取下一个表格。 如果此表是最后一个表,则引发 ItemNotFound 错误。

getNextOrNullObject()

获取下一个表格。 如果此表是最后一个表,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

getParagraphAfter()

获取 table 之后的 paragraph。 如果表后没有段落,则引发 ItemNotFound 错误。

getParagraphAfterOrNullObject()

获取 table 之后的 paragraph。 如果表后面没有段落,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

getParagraphBefore()

获取 table 之前的 paragraph。 如果表格前面没有段落,则引发 ItemNotFound 错误。

getParagraphBeforeOrNullObject()

获取 table 之前的 paragraph。 如果表格之前没有段落,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

getRange(rangeLocation)

获取包含此表格的范围,或包含此表格的开头或结尾的范围。

insertContentControl()

在表格中插入内容控件。

insertParagraph(paragraphText, insertLocation)

在指定位置插入段落。

insertTable(rowCount, columnCount, insertLocation, values)

插入包含指定行数和列数的 table。

load(options)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。

load(propertyNames)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。

mergeCells(topRow, firstCell, bottomRow, lastCell)

合并由第一个单元格和最后一个单元格(不含)包围的单元格。

reapplyAutoFormat()

使用调用该方法时设置的预定义表格格式的特征汇报表格autoFormat。 默认的预定义格式为 TableFormatType.none。

search(searchText, searchOptions)

使用指定的搜索选项对对象范围执行 Table 搜索。 搜索结果是对象的 Range 集合。

select(selectionMode)

选择表格或其开头或结尾位置,然后将 Word UI 导航到相应位置。

select(selectionMode)

选择表格或其开头或结尾位置,然后将 Word UI 导航到相应位置。

set(properties, options)

同时设置对象的多个属性。 可以传递具有相应属性的纯文本对象,也可以传递另一个相同类型的 API 对象。

set(properties)

基于现有加载的对象,同时在对象上设置多个属性。

setCellPadding(cellPaddingLocation, cellPadding)

设置单元格填充(以磅为单位)。

setCellPadding(cellPaddingLocation, cellPadding)

设置单元格填充(以磅为单位)。

sort(options)

对指定的表格进行排序。

toJSON()

覆盖 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 (JSON.stringify反过来调用 toJSON 传递给它的对象的方法。) 虽然原始 Word.Table 对象是 API 对象, toJSON 但该方法返回一个纯 JavaScript 对象, (类型化为 Word.Interfaces.TableData) ,其中包含从原始对象加载的任何子属性的浅层副本。

track()

根据文档中的相应更改来跟踪对象,以便进行自动调整。 此调用是 context.trackedObjects.add (thisObject) 的简写。 如果在调用中 .sync 使用此对象,并且在“.run”批处理的顺序执行之外使用此对象,并且在设置属性或对对象调用方法时收到“InvalidObjectPath”错误,则需要在首次创建对象时将对象添加到跟踪对象集合。 如果此对象是集合的一部分,您还应跟踪父集合。

untrack()

释放与此对象关联的内存(如果先前已跟踪过)。 此调用是 context.trackedObjects.remove (thisObject) 的简写。 拥有许多跟踪对象会降低主机应用程序的速度,因此请在使用完毕后释放所添加的任何对象。 需要在内存释放生效之前调用 context.sync() 。

属性详细信息

alignment

指定表与页列的对齐方式。 值可以是 left、 centered或 right。

alignment: Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified";

属性值

Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified"

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml

// Gets alignment details about the first table in the document.
await Word.run(async (context) => {
  const firstTable: Word.Table = context.document.body.tables.getFirst();
  firstTable.load(["alignment", "horizontalAlignment", "verticalAlignment"]);
  await context.sync();

  console.log(
    `Details about the alignment of the first table:`,
    `- Alignment of the table within the containing page column: ${firstTable.alignment}`,
    `- Horizontal alignment of every cell in the table: ${firstTable.horizontalAlignment}`,
    `- Vertical alignment of every cell in the table: ${firstTable.verticalAlignment}`,
  );
});

columns

返回 TableColumnCollection 表示表中列的对象。

readonly columns: Word.TableColumnCollection;

属性值

注解

API 集:WordApiDesktop 1.4

context

与对象关联的请求上下文。 这将加载项的进程连接到 Office 主机应用程序的进程。

context: RequestContext;

属性值

description

指定表的说明。

description: string;

属性值

string

注解

API 集:WordApiDesktop 1.4

endnotes

获取表中尾注的集合。

readonly endnotes: Word.NoteItemCollection;

属性值

注解

API 集:WordApi 1.5

fields

获取表中对象的 Field 集合。

readonly fields: Word.FieldCollection;

属性值

注解

API 集:WordApi 1.4

font

获取字体。 使用此关系可获取并设置字体名称、大小、颜色和其他属性。

readonly font: Word.Font;

属性值

注解

API 集:WordApi 1.3

footnotes

获取表中脚注的集合。

readonly footnotes: Word.NoteItemCollection;

属性值

注解

API 集:WordApi 1.5

headerRowCount

指定标题行数。

headerRowCount: number;

属性值

number

注解

API 集:WordApi 1.3

horizontalAlignment

指定表中每个单元格的水平对齐方式。 值可以是 left、centered 、right 或 。justified

horizontalAlignment: Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified";

属性值

Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified"

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml

// Gets alignment details about the first table in the document.
await Word.run(async (context) => {
  const firstTable: Word.Table = context.document.body.tables.getFirst();
  firstTable.load(["alignment", "horizontalAlignment", "verticalAlignment"]);
  await context.sync();

  console.log(
    `Details about the alignment of the first table:`,
    `- Alignment of the table within the containing page column: ${firstTable.alignment}`,
    `- Horizontal alignment of every cell in the table: ${firstTable.horizontalAlignment}`,
    `- Vertical alignment of every cell in the table: ${firstTable.verticalAlignment}`,
  );
});

isUniform

指明所有表行是否一致。

readonly isUniform: boolean;

属性值

boolean

注解

API 集:WordApi 1.3

nestingLevel

获取 table 的嵌套级别。 顶级 table 的级别为 1。

readonly nestingLevel: number;

属性值

number

注解

API 集:WordApi 1.3

parentBody

获取 table 的父正文。

readonly parentBody: Word.Body;

属性值

注解

API 集:WordApi 1.3

parentContentControl

获取包含 table 的 contentControl。 如果没有父内容控件,则引发 ItemNotFound 错误。

readonly parentContentControl: Word.ContentControl;

属性值

注解

API 集:WordApi 1.3

parentContentControlOrNullObject

获取包含 table 的 contentControl。 如果没有父内容控件,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

readonly parentContentControlOrNullObject: Word.ContentControl;

属性值

注解

API 集:WordApi 1.3

parentTable

获取包含此 table 的 table。 如果表中未包含,则引发 ItemNotFound 错误。

readonly parentTable: Word.Table;

属性值

注解

API 集:WordApi 1.3

parentTableCell

获取包含此 table 的 tableCell。 如果表单元格中未包含错误,则引发 ItemNotFound 错误。

readonly parentTableCell: Word.TableCell;

属性值

注解

API 集:WordApi 1.3

parentTableCellOrNullObject

获取包含此 table 的 tableCell。 如果它未包含在表单元格中,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

readonly parentTableCellOrNullObject: Word.TableCell;

属性值

注解

API 集:WordApi 1.3

parentTableOrNullObject

获取包含此 table 的 table。 如果它未包含在表中,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

readonly parentTableOrNullObject: Word.Table;

属性值

注解

API 集:WordApi 1.3

rowCount

获取表格中的行数。

readonly rowCount: number;

属性值

number

注解

API 集:WordApi 1.3

rows

获取所有表格行。

readonly rows: Word.TableRowCollection;

属性值

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml

// Gets content alignment details about the first row of the first table in the document.
await Word.run(async (context) => {
  const firstTable: Word.Table = context.document.body.tables.getFirst();
  const firstTableRow: Word.TableRow = firstTable.rows.getFirst();
  firstTableRow.load(["horizontalAlignment", "verticalAlignment"]);
  await context.sync();

  console.log(
    `Details about the alignment of the first table's first row:`,
    `- Horizontal alignment of every cell in the row: ${firstTableRow.horizontalAlignment}`,
    `- Vertical alignment of every cell in the row: ${firstTableRow.verticalAlignment}`,
  );
});

shading

返回 ShadingUniversal 表示表格底纹的对象。

readonly shading: Word.ShadingUniversal;

属性值

注解

API 集:WordApiDesktop 1.4

shadingColor

指定底纹颜色。 按“#RRGGBB”格式或使用颜色名称指定颜色。

shadingColor: string;

属性值

string

注解

API 集:WordApi 1.3

style

指定表格的样式名称。 请对自定义样式和本地化样式名称使用此属性。 若要使用可以在区域设置之间移植的嵌入样式,请参阅“styleBuiltIn”属性。

style: string;

属性值

string

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-custom-style.yaml

// Applies the specified style to a new table.
const styleName = (document.getElementById("style-name") as HTMLInputElement).value;
if (styleName == "") {
  console.warn("Enter a style name to apply.");
  return;
}

await Word.run(async (context) => {
  const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName);
  style.load();
  await context.sync();

  if (style.isNullObject) {
    console.warn(`There's no existing style with the name '${styleName}'.`);
  } else if (style.type != Word.StyleType.table) {
    console.warn(`The '${styleName}' style isn't a table style.`);
  } else {
    const body: Word.Body = context.document.body;
    body.clear();
    const data = [
      ["Tokyo", "Beijing", "Seattle"],
      ["Apple", "Orange", "Pineapple"]
    ];
    const table: Word.Table = body.insertTable(2, 3, "Start", data);
    table.style = style.nameLocal;
    table.styleFirstColumn = false;
    await context.sync();

    console.log(`'${styleName}' style applied to first table.`, style);
  }
});

styleBandedColumns

指定表是否具有带状列。

styleBandedColumns: boolean;

属性值

boolean

注解

API 集:WordApi 1.3

styleBandedRows

指定表是否具有带状行。

styleBandedRows: boolean;

属性值

boolean

注解

API 集:WordApi 1.3

styleBuiltIn

指定表的内置样式名称。 请对可以在区域设置之间移植的嵌入样式使用此属性。 若要使用自定义样式或本地化样式名称,请参阅“style”属性。

styleBuiltIn: Word.BuiltInStyleName | "Other" | "Normal" | "Heading1" | "Heading2" | "Heading3" | "Heading4" | "Heading5" | "Heading6" | "Heading7" | "Heading8" | "Heading9" | "Toc1" | "Toc2" | "Toc3" | "Toc4" | "Toc5" | "Toc6" | "Toc7" | "Toc8" | "Toc9" | "FootnoteText" | "Header" | "Footer" | "Caption" | "FootnoteReference" | "EndnoteReference" | "EndnoteText" | "Title" | "Subtitle" | "Hyperlink" | "Strong" | "Emphasis" | "NoSpacing" | "ListParagraph" | "Quote" | "IntenseQuote" | "SubtleEmphasis" | "IntenseEmphasis" | "SubtleReference" | "IntenseReference" | "BookTitle" | "Bibliography" | "TocHeading" | "TableGrid" | "PlainTable1" | "PlainTable2" | "PlainTable3" | "PlainTable4" | "PlainTable5" | "TableGridLight" | "GridTable1Light" | "GridTable1Light_Accent1" | "GridTable1Light_Accent2" | "GridTable1Light_Accent3" | "GridTable1Light_Accent4" | "GridTable1Light_Accent5" | "GridTable1Light_Accent6" | "GridTable2" | "GridTable2_Accent1" | "GridTable2_Accent2" | "GridTable2_Accent3" | "GridTable2_Accent4" | "GridTable2_Accent5" | "GridTable2_Accent6" | "GridTable3" | "GridTable3_Accent1" | "GridTable3_Accent2" | "GridTable3_Accent3" | "GridTable3_Accent4" | "GridTable3_Accent5" | "GridTable3_Accent6" | "GridTable4" | "GridTable4_Accent1" | "GridTable4_Accent2" | "GridTable4_Accent3" | "GridTable4_Accent4" | "GridTable4_Accent5" | "GridTable4_Accent6" | "GridTable5Dark" | "GridTable5Dark_Accent1" | "GridTable5Dark_Accent2" | "GridTable5Dark_Accent3" | "GridTable5Dark_Accent4" | "GridTable5Dark_Accent5" | "GridTable5Dark_Accent6" | "GridTable6Colorful" | "GridTable6Colorful_Accent1" | "GridTable6Colorful_Accent2" | "GridTable6Colorful_Accent3" | "GridTable6Colorful_Accent4" | "GridTable6Colorful_Accent5" | "GridTable6Colorful_Accent6" | "GridTable7Colorful" | "GridTable7Colorful_Accent1" | "GridTable7Colorful_Accent2" | "GridTable7Colorful_Accent3" | "GridTable7Colorful_Accent4" | "GridTable7Colorful_Accent5" | "GridTable7Colorful_Accent6" | "ListTable1Light" | "ListTable1Light_Accent1" | "ListTable1Light_Accent2" | "ListTable1Light_Accent3" | "ListTable1Light_Accent4" | "ListTable1Light_Accent5" | "ListTable1Light_Accent6" | "ListTable2" | "ListTable2_Accent1" | "ListTable2_Accent2" | "ListTable2_Accent3" | "ListTable2_Accent4" | "ListTable2_Accent5" | "ListTable2_Accent6" | "ListTable3" | "ListTable3_Accent1" | "ListTable3_Accent2" | "ListTable3_Accent3" | "ListTable3_Accent4" | "ListTable3_Accent5" | "ListTable3_Accent6" | "ListTable4" | "ListTable4_Accent1" | "ListTable4_Accent2" | "ListTable4_Accent3" | "ListTable4_Accent4" | "ListTable4_Accent5" | "ListTable4_Accent6" | "ListTable5Dark" | "ListTable5Dark_Accent1" | "ListTable5Dark_Accent2" | "ListTable5Dark_Accent3" | "ListTable5Dark_Accent4" | "ListTable5Dark_Accent5" | "ListTable5Dark_Accent6" | "ListTable6Colorful" | "ListTable6Colorful_Accent1" | "ListTable6Colorful_Accent2" | "ListTable6Colorful_Accent3" | "ListTable6Colorful_Accent4" | "ListTable6Colorful_Accent5" | "ListTable6Colorful_Accent6" | "ListTable7Colorful" | "ListTable7Colorful_Accent1" | "ListTable7Colorful_Accent2" | "ListTable7Colorful_Accent3" | "ListTable7Colorful_Accent4" | "ListTable7Colorful_Accent5" | "ListTable7Colorful_Accent6";

属性值

Word.BuiltInStyleName | "Other" | "Normal" | "Heading1" | "Heading2" | "Heading3" | "Heading4" | "Heading5" | "Heading6" | "Heading7" | "Heading8" | "Heading9" | "Toc1" | "Toc2" | "Toc3" | "Toc4" | "Toc5" | "Toc6" | "Toc7" | "Toc8" | "Toc9" | "FootnoteText" | "Header" | "Footer" | "Caption" | "FootnoteReference" | "EndnoteReference" | "EndnoteText" | "Title" | "Subtitle" | "Hyperlink" | "Strong" | "Emphasis" | "NoSpacing" | "ListParagraph" | "Quote" | "IntenseQuote" | "SubtleEmphasis" | "IntenseEmphasis" | "SubtleReference" | "IntenseReference" | "BookTitle" | "Bibliography" | "TocHeading" | "TableGrid" | "PlainTable1" | "PlainTable2" | "PlainTable3" | "PlainTable4" | "PlainTable5" | "TableGridLight" | "GridTable1Light" | "GridTable1Light_Accent1" | "GridTable1Light_Accent2" | "GridTable1Light_Accent3" | "GridTable1Light_Accent4" | "GridTable1Light_Accent5" | "GridTable1Light_Accent6" | "GridTable2" | "GridTable2_Accent1" | "GridTable2_Accent2" | "GridTable2_Accent3" | "GridTable2_Accent4" | "GridTable2_Accent5" | "GridTable2_Accent6" | "GridTable3" | "GridTable3_Accent1" | "GridTable3_Accent2" | "GridTable3_Accent3" | "GridTable3_Accent4" | "GridTable3_Accent5" | "GridTable3_Accent6" | "GridTable4" | "GridTable4_Accent1" | "GridTable4_Accent2" | "GridTable4_Accent3" | "GridTable4_Accent4" | "GridTable4_Accent5" | "GridTable4_Accent6" | "GridTable5Dark" | "GridTable5Dark_Accent1" | "GridTable5Dark_Accent2" | "GridTable5Dark_Accent3" | "GridTable5Dark_Accent4" | "GridTable5Dark_Accent5" | "GridTable5Dark_Accent6" | "GridTable6Colorful" | "GridTable6Colorful_Accent1" | "GridTable6Colorful_Accent2" | "GridTable6Colorful_Accent3" | "GridTable6Colorful_Accent4" | "GridTable6Colorful_Accent5" | "GridTable6Colorful_Accent6" | "GridTable7Colorful" | "GridTable7Colorful_Accent1" | "GridTable7Colorful_Accent2" | "GridTable7Colorful_Accent3" | "GridTable7Colorful_Accent4" | "GridTable7Colorful_Accent5" | "GridTable7Colorful_Accent6" | "ListTable1Light" | "ListTable1Light_Accent1" | "ListTable1Light_Accent2" | "ListTable1Light_Accent3" | "ListTable1Light_Accent4" | "ListTable1Light_Accent5" | "ListTable1Light_Accent6" | "ListTable2" | "ListTable2_Accent1" | "ListTable2_Accent2" | "ListTable2_Accent3" | "ListTable2_Accent4" | "ListTable2_Accent5" | "ListTable2_Accent6" | "ListTable3" | "ListTable3_Accent1" | "ListTable3_Accent2" | "ListTable3_Accent3" | "ListTable3_Accent4" | "ListTable3_Accent5" | "ListTable3_Accent6" | "ListTable4" | "ListTable4_Accent1" | "ListTable4_Accent2" | "ListTable4_Accent3" | "ListTable4_Accent4" | "ListTable4_Accent5" | "ListTable4_Accent6" | "ListTable5Dark" | "ListTable5Dark_Accent1" | "ListTable5Dark_Accent2" | "ListTable5Dark_Accent3" | "ListTable5Dark_Accent4" | "ListTable5Dark_Accent5" | "ListTable5Dark_Accent6" | "ListTable6Colorful" | "ListTable6Colorful_Accent1" | "ListTable6Colorful_Accent2" | "ListTable6Colorful_Accent3" | "ListTable6Colorful_Accent4" | "ListTable6Colorful_Accent5" | "ListTable6Colorful_Accent6" | "ListTable7Colorful" | "ListTable7Colorful_Accent1" | "ListTable7Colorful_Accent2" | "ListTable7Colorful_Accent3" | "ListTable7Colorful_Accent4" | "ListTable7Colorful_Accent5" | "ListTable7Colorful_Accent6"

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/55-selection/insert-formula.yaml

await Word.run(async (context) => {
  const body: Word.Body = context.document.body;
  body.clear();

  body.insertParagraph("Sales data", Word.InsertLocation.start);

  // Create a table with numeric values and an empty total row.
  const table: Word.Table = body.insertTable(5, 2, Word.InsertLocation.end, [
    ["Item", "Amount"],
    ["Product A", "1200"],
    ["Product B", "3450"],
    ["Product C", "870"],
    ["Total", ""],
  ]);
  table.styleBuiltIn = Word.BuiltInStyleName.tableGrid;

  await context.sync();

  console.log(
    "Setup complete. Place your cursor in the empty 'Total' cell (last row, second column), then try inserting a formula.",
  );
});

styleFirstColumn

指定表的第一列是否具有特殊样式。

styleFirstColumn: boolean;

属性值

boolean

注解

API 集:WordApi 1.3

styleLastColumn

指定表的最后一列是否具有特殊样式。

styleLastColumn: boolean;

属性值

boolean

注解

API 集:WordApi 1.3

styleTotalRow

指定表是否具有具有特殊样式 (最后) 行的总和。

styleTotalRow: boolean;

属性值

boolean

注解

API 集:WordApi 1.3

tables

获取嵌套一级的子 table。

readonly tables: Word.TableCollection;

属性值

注解

API 集:WordApi 1.3

title

指定表的标题。

title: string;

属性值

string

注解

API 集:WordApiDesktop 1.4

values

将表中的文本值指定为 2D JavaScript 数组。

values: string[][];

属性值

string[][]

注解

API 集:WordApi 1.3

verticalAlignment

指定表格中每个单元格的垂直对齐方式。 值可以是 top、 center或 bottom。

verticalAlignment: Word.VerticalAlignment | "Mixed" | "Top" | "Center" | "Bottom";

属性值

Word.VerticalAlignment | "Mixed" | "Top" | "Center" | "Bottom"

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml

// Gets alignment details about the first table in the document.
await Word.run(async (context) => {
  const firstTable: Word.Table = context.document.body.tables.getFirst();
  firstTable.load(["alignment", "horizontalAlignment", "verticalAlignment"]);
  await context.sync();

  console.log(
    `Details about the alignment of the first table:`,
    `- Alignment of the table within the containing page column: ${firstTable.alignment}`,
    `- Horizontal alignment of every cell in the table: ${firstTable.horizontalAlignment}`,
    `- Vertical alignment of every cell in the table: ${firstTable.verticalAlignment}`,
  );
});

width

指定表的宽度(以磅为单位)。

width: number;

属性值

number

注解

API 集:WordApi 1.3

方法详细信息

addColumns(insertLocation, columnCount, values)

使用第一个或最后一个现有列作为模板,将列添加到 table 的开头或结尾。 此方法适用于一致的 table。 字符串值(若指定)是在新插入的行中进行设置。

addColumns(insertLocation: Word.InsertLocation.start | Word.InsertLocation.end | "Start" | "End", columnCount: number, values?: string[][]): void;

参数

insertLocation

start | end | "Start" | "End"

它必须是 start 或 end,对应于表的相应一侧。

columnCount

number

要添加的列数。

values

string[][]

可选的二维数组。 如果指定数组中的对应字符串,则填充单元格。

返回

void

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-table-structure.yaml

// Adds a column to the end of the first table.
await Word.run(async (context) => {
  const salesTable: Word.Table = context.document.body.tables.getFirst();
  salesTable.addColumns(Word.InsertLocation.end, 1);

  await context.sync();
  console.log("Added a column to the end of the sales table.");
});

addRows(insertLocation, rowCount, values)

使用第一个或最后一个现有行作为模板,将行添加到 table 的开头或结尾。 字符串值(若指定)是在新插入的行中进行设置。

addRows(insertLocation: Word.InsertLocation.start | Word.InsertLocation.end | "Start" | "End", rowCount: number, values?: string[][]): Word.TableRowCollection;

参数

insertLocation

start | end | "Start" | "End"

它必须是 start OR end。

rowCount

number

要添加的行数。

values

string[][]

可选的二维数组。 如果指定数组中的对应字符串,则填充单元格。

返回

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-table-structure.yaml

// Adds a row to the end of the first table.
await Word.run(async (context) => {
  const salesTable: Word.Table = context.document.body.tables.getFirst();
  salesTable.addRows(Word.InsertLocation.end, 1);

  await context.sync();
  console.log("Added a row to the end of the sales table.");
});

applyStyleDirectFormatting(styleName)

应用指定的样式,但保留用户直接应用的所有格式。

applyStyleDirectFormatting(styleName: string): void;

参数

styleName

string

要应用的样式的名称。

返回

void

注解

API 集:WordApiDesktop 1.4

autoFitBehavior(behavior)

确定 Microsoft Word 如何使用自动调整功能来调整表格的大小。

autoFitBehavior(behavior: Word.AutoFitBehavior): void;

参数

behavior
Word.AutoFitBehavior

指定 Word 如何使用"自动调整"功能重新调整指定表格的大小。

返回

void

注解

API 集:WordApiDesktop 1.4

autoFitBehavior(behavior)

确定 Microsoft Word 如何使用自动调整功能来调整表格的大小。

autoFitBehavior(behavior: "FixedSize" | "Content" | "Window"): void;

参数

behavior

"FixedSize" | "Content" | "Window"

指定 Word 如何使用"自动调整"功能重新调整指定表格的大小。

返回

void

注解

API 集:WordApiDesktop 1.4

autoFitWindow()

自动调整表列,以适应窗口的宽度。

autoFitWindow(): void;

返回

void

注解

API 集:WordApi 1.3

autoFormat(options)

将预定义外观应用于表格。

autoFormat(options?: Word.TableAutoFormatOptions): void;

参数

options
Word.TableAutoFormatOptions

可选。 指定用于应用表格格式的选项的对象。

返回

void

注解

API 集:WordApiDesktop 1.4

clear()

清除表内容。

clear(): void;

返回

void

注解

API 集:WordApi 1.3

convertToText(options)

将表格转换为文本。

convertToText(options?: Word.TableConvertToTextOptions): Word.Range;

参数

options
Word.TableConvertToTextOptions

可选。 指定用于将表格转换为文本的选项的对象。

返回

Range表示已转换文本的对象。

注解

API 集:WordApiDesktop 1.4

delete()

删除整个表格。

delete(): void;

返回

void

注解

API 集:WordApi 1.3

deleteColumns(columnIndex, columnCount)

删除特定的列。 此方法适用于一致的 table。

deleteColumns(columnIndex: number, columnCount?: number): void;

参数

columnIndex

number

要删除的第一列。

columnCount

number

可选。 要删除的列数。 默认值 1。

返回

void

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-table-structure.yaml

// Deletes the last column while keeping at least one column in the table.
await Word.run(async (context) => {
  const salesTable: Word.Table = context.document.body.tables.getFirst();
  const firstRow: Word.TableRow = salesTable.rows.getFirst();
  firstRow.load("cellCount");
  await context.sync();

  if (firstRow.cellCount <= 1) {
    console.warn("Keep at least one column. Add a column or choose Set up to reset the sample.");
    return;
  }

  salesTable.deleteColumns(firstRow.cellCount - 1, 1);
  await context.sync();
  console.log("Deleted the last column of the sales table.");
});

deleteRows(rowIndex, rowCount)

删除特定的行。

deleteRows(rowIndex: number, rowCount?: number): void;

参数

rowIndex

number

要删除的第一行。

rowCount

number

可选。 要删除的行数。 默认值 1。

返回

void

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-table-structure.yaml

// Deletes the last row while keeping the table's header row.
await Word.run(async (context) => {
  const salesTable: Word.Table = context.document.body.tables.getFirst();
  salesTable.load("rowCount");
  await context.sync();

  if (salesTable.rowCount <= 1) {
    console.warn("Keep the header row. Add a row or choose Set up to reset the sample.");
    return;
  }

  salesTable.deleteRows(salesTable.rowCount - 1, 1);
  await context.sync();
  console.log("Deleted the last row of the sales table.");
});

distributeColumns()

将列设置为等宽。 此方法适用于一致的 table。

distributeColumns(): void;

返回

void

注解

API 集:WordApi 1.3

getBorder(borderLocation)

获取指定边框的边框样式。

getBorder(borderLocation: Word.BorderLocation): Word.TableBorder;

参数

borderLocation
Word.BorderLocation

边框位置。

返回

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml

// Gets border details about the first table in the document.
await Word.run(async (context) => {
  const firstTable: Word.Table = context.document.body.tables.getFirst();
  const borderLocation = Word.BorderLocation.top;
  const border: Word.TableBorder = firstTable.getBorder(borderLocation);
  border.load(["type", "color", "width"]);
  await context.sync();

  console.log(
    `Details about the ${borderLocation} border of the first table:`,
    `- Color: ${border.color}`,
    `- Type: ${border.type}`,
    `- Width: ${border.width} points`,
  );
});

getBorder(borderLocation)

获取指定边框的边框样式。

getBorder(borderLocation: "Top" | "Left" | "Bottom" | "Right" | "InsideHorizontal" | "InsideVertical" | "Inside" | "Outside" | "All"): Word.TableBorder;

参数

borderLocation

"Top" | "Left" | "Bottom" | "Right" | "InsideHorizontal" | "InsideVertical" | "Inside" | "Outside" | "All"

边框位置。

返回

注解

API 集:WordApi 1.3

getCell(rowIndex, cellIndex)

获取指定行和列处的表单元格。 如果指定的表单元格不存在,则引发 ItemNotFound 错误。

getCell(rowIndex: number, cellIndex: number): Word.TableCell;

参数

rowIndex

number

行的索引。

cellIndex

number

行中单元格的索引。

返回

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/table-cell-access.yaml

// Gets the content of the first cell in the first table.
await Word.run(async (context) => {
  const firstCell: Word.Body = context.document.body.tables.getFirst().getCell(0, 0).body;
  firstCell.load("text");

  await context.sync();
  console.log("First cell's text is: " + firstCell.text);
});

getCellOrNullObject(rowIndex, cellIndex)

获取指定行和列处的表单元格。 如果指定的表单元格不存在,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

getCellOrNullObject(rowIndex: number, cellIndex: number): Word.TableCell;

参数

rowIndex

number

行的索引。

cellIndex

number

行中单元格的索引。

返回

注解

API 集:WordApi 1.3

getCellPadding(cellPaddingLocation)

获取单元格填充(以磅为单位)。

getCellPadding(cellPaddingLocation: Word.CellPaddingLocation): OfficeExtension.ClientResult<number>;

参数

cellPaddingLocation
Word.CellPaddingLocation

单元格填充位置必须是 top、left 、bottom 或 。right

返回

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml

// Gets cell padding details about the first table in the document.
await Word.run(async (context) => {
  const firstTable: Word.Table = context.document.body.tables.getFirst();
  const cellPaddingLocation = Word.CellPaddingLocation.right;
  const cellPadding = firstTable.getCellPadding(cellPaddingLocation);
  await context.sync();

  console.log(
    `Cell padding details about the ${cellPaddingLocation} border of the first table: ${cellPadding.value} points`,
  );
});

getCellPadding(cellPaddingLocation)

获取单元格填充(以磅为单位)。

getCellPadding(cellPaddingLocation: "Top" | "Left" | "Bottom" | "Right"): OfficeExtension.ClientResult<number>;

参数

cellPaddingLocation

"Top" | "Left" | "Bottom" | "Right"

单元格填充位置必须是 top、left 、bottom 或 。right

返回

注解

API 集:WordApi 1.3

getNext()

获取下一个表格。 如果此表是最后一个表,则引发 ItemNotFound 错误。

getNext(): Word.Table;

返回

注解

API 集:WordApi 1.3

getNextOrNullObject()

获取下一个表格。 如果此表是最后一个表,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

getNextOrNullObject(): Word.Table;

返回

注解

API 集:WordApi 1.3

getParagraphAfter()

获取 table 之后的 paragraph。 如果表后没有段落,则引发 ItemNotFound 错误。

getParagraphAfter(): Word.Paragraph;

返回

注解

API 集:WordApi 1.3

getParagraphAfterOrNullObject()

获取 table 之后的 paragraph。 如果表后面没有段落,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

getParagraphAfterOrNullObject(): Word.Paragraph;

返回

注解

API 集:WordApi 1.3

getParagraphBefore()

获取 table 之前的 paragraph。 如果表格前面没有段落,则引发 ItemNotFound 错误。

getParagraphBefore(): Word.Paragraph;

返回

注解

API 集:WordApi 1.3

getParagraphBeforeOrNullObject()

获取 table 之前的 paragraph。 如果表格之前没有段落,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。

getParagraphBeforeOrNullObject(): Word.Paragraph;

返回

注解

API 集:WordApi 1.3

getRange(rangeLocation)

获取包含此表格的范围,或包含此表格的开头或结尾的范围。

getRange(rangeLocation?: Word.RangeLocation.whole | Word.RangeLocation.start | Word.RangeLocation.end | Word.RangeLocation.after | "Whole" | "Start" | "End" | "After"): Word.Range;

参数

rangeLocation

whole | start | end | after | "Whole" | "Start" | "End" | "After"

可选。 范围位置必须为 whole、 、 endstart或 。after

返回

注解

API 集:WordApi 1.3

insertContentControl()

在表格中插入内容控件。

insertContentControl(): Word.ContentControl;

返回

注解

API 集:WordApi 1.3

insertParagraph(paragraphText, insertLocation)

在指定位置插入段落。

insertParagraph(paragraphText: string, insertLocation: Word.InsertLocation.before | Word.InsertLocation.after | "Before" | "After"): Word.Paragraph;

参数

paragraphText

string

要插入的段落文本。

insertLocation

before | after | "Before" | "After"

值必须为 OR 。beforeafter

返回

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-table-structure.yaml

// Inserts a heading before the first table.
await Word.run(async (context) => {
  const salesTable: Word.Table = context.document.body.tables.getFirst();
  const heading: Word.Paragraph = salesTable.insertParagraph("Quarterly sales", Word.InsertLocation.before);
  heading.font.bold = true;
  heading.font.color = "#000000";
  await context.sync();
  console.log("Inserted a heading before the sales table.");
});

insertTable(rowCount, columnCount, insertLocation, values)

插入包含指定行数和列数的 table。

insertTable(rowCount: number, columnCount: number, insertLocation: Word.InsertLocation.before | Word.InsertLocation.after | "Before" | "After", values?: string[][]): Word.Table;

参数

rowCount

number

表格的行数。

columnCount

number

表格的列数。

insertLocation

before | after | "Before" | "After"

值必须为 OR 。beforeafter

values

string[][]

可选的二维数组。 如果指定数组中的对应字符串,则填充单元格。

返回

注解

API 集:WordApi 1.3

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-table-structure.yaml

// Inserts a notes table after the first table.
await Word.run(async (context) => {
  const salesTable: Word.Table = context.document.body.tables.getFirst();
  const notesTable: Word.Table = salesTable.insertTable(2, 2, Word.InsertLocation.after, [
    ["Item", "Note"],
    ["Sales", "Review quarterly totals."]
  ]);
  notesTable.styleBuiltIn = Word.BuiltInStyleName.gridTable5Dark_Accent2;

  await context.sync();
  console.log("Inserted a notes table after the sales table.");
});

load(options)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。

load(options?: Word.Interfaces.TableLoadOptions): Word.Table;

参数

options
Word.Interfaces.TableLoadOptions

为要加载的对象属性提供选项。

返回

load(propertyNames)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。

load(propertyNames?: string | string[]): Word.Table;

参数

propertyNames

string | string[]

指定要加载的属性的逗号分隔的字符串或字符串数组。

返回

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Word.Table;

参数

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select 是指定要加载的属性的逗号分隔字符串,以及 propertyNamesAndPaths.expand 指定要加载的导航属性的逗号分隔字符串。

返回

mergeCells(topRow, firstCell, bottomRow, lastCell)

合并由第一个单元格和最后一个单元格(不含)包围的单元格。

mergeCells(topRow: number, firstCell: number, bottomRow: number, lastCell: number): Word.TableCell;

参数

topRow

number

第一个单元格的行。

firstCell

number

该行中第一个单元格的索引。

bottomRow

number

最后一个单元格的行。

lastCell

number

该行中最后一个单元格的索引。

返回

注解

API 集:WordApi 1.4

reapplyAutoFormat()

使用调用该方法时设置的预定义表格格式的特征汇报表格autoFormat。 默认的预定义格式为 TableFormatType.none。

reapplyAutoFormat(): void;

返回

void

注解

API 集:WordApiDesktop 1.4

search(searchText, searchOptions)

使用指定的搜索选项对对象范围执行 Table 搜索。 搜索结果是对象的 Range 集合。

search(searchText: string, searchOptions?: Word.SearchOptions | {
            ignorePunct?: boolean;
            ignoreSpace?: boolean;
            matchCase?: boolean;
            matchPrefix?: boolean;
            matchSuffix?: boolean;
            matchWholeWord?: boolean;
            matchWildcards?: boolean;
        }): Word.RangeCollection;

参数

searchText

string

搜索文本。

searchOptions

Word.SearchOptions | { ignorePunct?: boolean; ignoreSpace?: boolean; matchCase?: boolean; matchPrefix?: boolean; matchSuffix?: boolean; matchWholeWord?: boolean; matchWildcards?: boolean; }

可选。 用于搜索的选项。

返回

注解

API 集:WordApi 1.3

select(selectionMode)

选择表格或其开头或结尾位置,然后将 Word UI 导航到相应位置。

select(selectionMode?: Word.SelectionMode): void;

参数

selectionMode
Word.SelectionMode

可选。 选择模式必须为 select、 、start 或 end。 select 为默认值。

返回

void

注解

API 集:WordApi 1.3

select(selectionMode)

选择表格或其开头或结尾位置,然后将 Word UI 导航到相应位置。

select(selectionMode?: "Select" | "Start" | "End"): void;

参数

selectionMode

"Select" | "Start" | "End"

可选。 选择模式必须为 select、 、start 或 end。 select 为默认值。

返回

void

注解

API 集:WordApi 1.3

set(properties, options)

同时设置对象的多个属性。 可以传递具有相应属性的纯文本对象,也可以传递另一个相同类型的 API 对象。

set(properties: Interfaces.TableUpdateData, options?: OfficeExtension.UpdateOptions): void;

参数

properties
Word.Interfaces.TableUpdateData

一个 JavaScript 对象,其属性与调用该方法的对象的属性同构结构。

options
OfficeExtension.UpdateOptions

提供一个选项,用于在 properties 对象尝试设置任何只读属性时禁止错误。

返回

void

set(properties)

基于现有加载的对象,同时在对象上设置多个属性。

set(properties: Word.Table): void;

参数

properties
Word.Table

返回

void

setCellPadding(cellPaddingLocation, cellPadding)

设置单元格填充(以磅为单位)。

setCellPadding(cellPaddingLocation: Word.CellPaddingLocation, cellPadding: number): void;

参数

cellPaddingLocation
Word.CellPaddingLocation

单元格填充位置必须是 top、left 、bottom 或 。right

cellPadding

number

单元格填充。

返回

void

注解

API 集:WordApi 1.3

setCellPadding(cellPaddingLocation, cellPadding)

设置单元格填充(以磅为单位)。

setCellPadding(cellPaddingLocation: "Top" | "Left" | "Bottom" | "Right", cellPadding: number): void;

参数

cellPaddingLocation

"Top" | "Left" | "Bottom" | "Right"

单元格填充位置必须是 top、left 、bottom 或 。right

cellPadding

number

单元格填充。

返回

void

注解

API 集:WordApi 1.3

sort(options)

对指定的表格进行排序。

sort(options?: Word.TableSortOptions): void;

参数

options
Word.TableSortOptions

可选。 指定对表格排序的选项的对象。

返回

void

注解

API 集:WordApiDesktop 1.4

toJSON()

覆盖 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 (JSON.stringify反过来调用 toJSON 传递给它的对象的方法。) 虽然原始 Word.Table 对象是 API 对象, toJSON 但该方法返回一个纯 JavaScript 对象, (类型化为 Word.Interfaces.TableData) ,其中包含从原始对象加载的任何子属性的浅层副本。

toJSON(): Word.Interfaces.TableData;

返回

track()

根据文档中的相应更改来跟踪对象,以便进行自动调整。 此调用是 context.trackedObjects.add (thisObject) 的简写。 如果在调用中 .sync 使用此对象,并且在“.run”批处理的顺序执行之外使用此对象,并且在设置属性或对对象调用方法时收到“InvalidObjectPath”错误,则需要在首次创建对象时将对象添加到跟踪对象集合。 如果此对象是集合的一部分,您还应跟踪父集合。

track(): Word.Table;

返回

untrack()

释放与此对象关联的内存(如果先前已跟踪过)。 此调用是 context.trackedObjects.remove (thisObject) 的简写。 拥有许多跟踪对象会降低主机应用程序的速度,因此请在使用完毕后释放所添加的任何对象。 需要在内存释放生效之前调用 context.sync() 。

untrack(): Word.Table;

返回