Word.Table class 
表示Word文档中的表。
注解
示例
// 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 | 指定表与页面列的对齐方式。 该值可以是  | 
| columns | 返回  | 
| context | 与 对象关联的请求上下文。 这会将加载项的进程连接到 Office 主机应用程序的进程。 | 
| description | 指定表的说明。 | 
| endnotes | 获取表中尾注的集合。 | 
| fields | 获取表中对象的  | 
| font | 获取字体。 使用此关系可获取并设置字体名称、大小、颜色和其他属性。 | 
| footnotes | 获取表中脚注的集合。 | 
| header | 指定标题行数。 | 
| horizontal | 指定表格中每个单元格的水平对齐方式。 该值可以是  | 
| is | 指明所有表行是否一致。 | 
| nesting | 获取 table 的嵌套级别。 顶级 table 的级别为 1。 | 
| parent | 获取 table 的父正文。 | 
| parent | 获取包含 table 的 contentControl。 
               | 
| parent | 获取包含 table 的 contentControl。 如果没有父内容控件,则此方法将返回其属性设置为  | 
| parent | 获取包含此 table 的 table。 
               | 
| parent | 获取包含此 table 的 tableCell。 
               | 
| parent | 获取包含此 table 的 tableCell。 如果它未包含在表单元格中,则此方法将返回其  | 
| parent | 获取包含此 table 的 table。 如果它未包含在表中,则此方法将返回一个 对象,其  | 
| row | 获取表格中的行数。 | 
| rows | 获取所有表格行。 | 
| shading | 返回  | 
| shading | 指定底纹颜色。 按“#RRGGBB”格式或使用颜色名称指定颜色。 | 
| style | 指定表的样式名称。 请对自定义样式和本地化样式名称使用此属性。 若要使用可以在区域设置之间移植的嵌入样式,请参阅“styleBuiltIn”属性。 | 
| style | 指定表是否具有带状列。 | 
| style | 指定表是否具有带带行。 | 
| style | 指定表的内置样式名称。 请对可以在区域设置之间移植的嵌入样式使用此属性。 若要使用自定义样式或本地化样式名称,请参阅“style”属性。 | 
| style | 指定表是否具有具有特殊样式的第一列。 | 
| style | 指定表是否具有具有特殊样式的最后一列。 | 
| style | 指定表是否具有具有特殊样式的最后一) 行的总 (。 | 
| tables | 获取嵌套一级的子 table。 | 
| title | 指定表的标题。 | 
| values | 将表中的文本值指定为 2D JavaScript 数组。 | 
| vertical | 指定表格中每个单元格的垂直对齐方式。 该值可以是  | 
| width | 指定表的宽度(以磅为单位)。 | 
方法
| add | 使用第一个或最后一个现有列作为模板,将列添加到 table 的开头或结尾。 此方法适用于一致的 table。 字符串值(若指定)是在新插入的行中进行设置。 | 
| add | 使用第一个或最后一个现有行作为模板,将行添加到 table 的开头或结尾。 字符串值(若指定)是在新插入的行中进行设置。 | 
| apply | 应用指定的样式,但保留用户直接应用的所有格式。 | 
| auto | 确定 Microsoft Word 如何使用自动调整功能来调整表格的大小。 | 
| auto | 确定 Microsoft Word 如何使用自动调整功能来调整表格的大小。 | 
| auto | 自动调整表列,以适应窗口的宽度。 | 
| auto | 将预定义外观应用于表格。 | 
| clear() | 清除表内容。 | 
| convert | 将表格转换为文本。 | 
| delete() | 删除整个表格。 | 
| delete | 删除特定的列。 此方法适用于一致的 table。 | 
| delete | 删除特定的行。 | 
| distribute | 将列设置为等宽。 此方法适用于一致的 table。 | 
| get | 获取指定边框的边框样式。 | 
| get | 获取指定边框的边框样式。 | 
| get | 获取指定行和列处的表单元格。 
               | 
| get | 获取指定行和列处的表单元格。 如果指定的表单元格不存在,则此方法将返回其属性设置为  | 
| get | 获取单元格填充(以磅为单位)。 | 
| get | 获取单元格填充(以磅为单位)。 | 
| get | 获取下一个表格。 如果此表是最后一个  | 
| get | 获取下一个表格。 如果此表是最后一个表,则此方法将返回其属性设置为  | 
| get | 获取 table 之后的 paragraph。 
               | 
| get | 获取 table 之后的 paragraph。 如果表后没有段落,则此方法将返回其属性设置为  | 
| get | 获取 table 之前的 paragraph。 
               | 
| get | 获取 table 之前的 paragraph。 如果表前没有段落,则此方法将返回其属性设置为  | 
| get | 获取包含此表格的范围,或包含此表格的开头或结尾的范围。 | 
| insert | 在表格中插入内容控件。 | 
| insert | 在指定位置插入段落。 | 
| insert | 插入包含指定行数和列数的 table。 | 
| load(options) | 将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用  | 
| load(property | 将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用  | 
| load(property | 将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用  | 
| merge | 合并由第一个单元格和最后一个单元格绑定的单元格。 | 
| reapply | 在调用 方法时,汇报具有预定义表格式设置的特征的 | 
| search(search | 对对象范围  | 
| select(selection | 选择表格或其开头或结尾位置,然后将 Word UI 导航到相应位置。 | 
| select(selection | 选择表格或其开头或结尾位置,然后将 Word UI 导航到相应位置。 | 
| set(properties, options) | 同时设置对象的多个属性。 可以传递具有相应属性的纯对象,也可以传递同一类型的另一个 API 对象。 | 
| set(properties) | 基于现有的已加载对象,同时对对象设置多个属性。 | 
| set | 设置单元格填充(以磅为单位)。 | 
| set | 设置单元格填充(以磅为单位)。 | 
| sort(options) | 对指定的表格进行排序。 | 
| toJSON() | 重写 JavaScript  | 
| track() | 根据文档中的相应更改来跟踪对象,以便进行自动调整。 此调用是 context.trackedObjects.add (thisObject) 的简写。 如果跨  | 
| untrack() | 释放与此对象关联的内存(如果先前已跟踪过)。 此调用是 context.trackedObjects.remove (thisObject) 的简写。 拥有许多跟踪对象会降低主机应用程序的速度,因此请在使用完毕后释放所添加的任何对象。 在内存发布生效之前,需要调用  | 
属性详细信息
alignment
指定表与页面列的对齐方式。 该值可以是 left、 centered或 right。
alignment: Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified";属性值
Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified"
注解
示例
// 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;属性值
注解
context
description
endnotes
获取表中尾注的集合。
readonly endnotes: Word.NoteItemCollection;属性值
注解
fields
获取表中对象的 Field 集合。
readonly fields: Word.FieldCollection;属性值
注解
font
footnotes
获取表中脚注的集合。
readonly footnotes: Word.NoteItemCollection;属性值
注解
		headerRowCount
	  
	
		horizontalAlignment
	 
	指定表格中每个单元格的水平对齐方式。 该值可以是 left、centered、right 或 。justified
horizontalAlignment: Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified";属性值
Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified"
注解
示例
// 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
	 
	
		nestingLevel
	 
	
		parentBody
	 
	
		parentContentControl
	  
	获取包含 table 的 contentControl。 
              ItemNotFound如果没有父内容控件,则引发错误。
readonly parentContentControl: Word.ContentControl;属性值
注解
		parentContentControlOrNullObject
	    
	获取包含 table 的 contentControl。 如果没有父内容控件,则此方法将返回其属性设置为 true的对象isNullObject。 有关详细信息,请参阅 *OrNullObject 方法和属性。
readonly parentContentControlOrNullObject: Word.ContentControl;属性值
注解
		parentTable
	 
	获取包含此 table 的 table。 
              ItemNotFound如果未包含在表中,则引发错误。
readonly parentTable: Word.Table;属性值
注解
		parentTableCell
	  
	获取包含此 table 的 tableCell。 
              ItemNotFound如果表单元格中未包含错误,则引发错误。
readonly parentTableCell: Word.TableCell;属性值
注解
		parentTableCellOrNullObject
	    
	获取包含此 table 的 tableCell。 如果它未包含在表单元格中,则此方法将返回其 isNullObject 属性设置为 true的对象。 有关详细信息,请参阅 *OrNullObject 方法和属性。
readonly parentTableCellOrNullObject: Word.TableCell;属性值
注解
		parentTableOrNullObject
	   
	获取包含此 table 的 table。 如果它未包含在表中,则此方法将返回一个 对象,其 isNullObject 属性设置为 true。 有关详细信息,请参阅 *OrNullObject 方法和属性。
readonly parentTableOrNullObject: Word.Table;属性值
注解
		rowCount
	 
	
rows
获取所有表格行。
readonly rows: Word.TableRowCollection;属性值
注解
示例
// 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;属性值
注解
		shadingColor
	 
	
style
指定表的样式名称。 请对自定义样式和本地化样式名称使用此属性。 若要使用可以在区域设置之间移植的嵌入样式,请参阅“styleBuiltIn”属性。
style: string;属性值
string
注解
		styleBandedColumns
	  
	
		styleBandedRows
	  
	
		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"
注解
		styleFirstColumn
	  
	
		styleLastColumn
	  
	
		styleTotalRow
	  
	
tables
获取嵌套一级的子 table。
readonly tables: Word.TableCollection;属性值
注解
title
values
		verticalAlignment
	 
	指定表格中每个单元格的垂直对齐方式。 该值可以是 top、 center或 bottom。
verticalAlignment: Word.VerticalAlignment | "Mixed" | "Top" | "Center" | "Bottom";属性值
Word.VerticalAlignment | "Mixed" | "Top" | "Center" | "Bottom"
注解
示例
// 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
方法详细信息
		addColumns(insertLocation, columnCount, values)
	   
	使用第一个或最后一个现有列作为模板,将列添加到 table 的开头或结尾。 此方法适用于一致的 table。 字符串值(若指定)是在新插入的行中进行设置。
addColumns(insertLocation: Word.InsertLocation.start | Word.InsertLocation.end | "Start" | "End", columnCount: number, values?: string[][]): void;参数
- columnCount
- 
				number 
要添加的列数。
- values
- 
				string[][] 
可选的二维数组。 如果指定数组中的对应字符串,则填充单元格。
返回
void
注解
		addRows(insertLocation, rowCount, values)
	   
	使用第一个或最后一个现有行作为模板,将行添加到 table 的开头或结尾。 字符串值(若指定)是在新插入的行中进行设置。
addRows(insertLocation: Word.InsertLocation.start | Word.InsertLocation.end | "Start" | "End", rowCount: number, values?: string[][]): Word.TableRowCollection;参数
- rowCount
- 
				number 
要添加的行数。
- values
- 
				string[][] 
可选的二维数组。 如果指定数组中的对应字符串,则填充单元格。
返回
注解
		applyStyleDirectFormatting(styleName)
	    
	应用指定的样式,但保留用户直接应用的所有格式。
applyStyleDirectFormatting(styleName: string): void;参数
- styleName
- 
				string 
要应用的样式的名称。
返回
void
注解
		autoFitBehavior(behavior)
	  
	确定 Microsoft Word 如何使用自动调整功能来调整表格的大小。
autoFitBehavior(behavior: Word.AutoFitBehavior): void;参数
- behavior
- Word.AutoFitBehavior
指定 Word 如何使用"自动调整"功能重新调整指定表格的大小。
返回
void
注解
		autoFitBehavior(behavior)
	  
	确定 Microsoft Word 如何使用自动调整功能来调整表格的大小。
autoFitBehavior(behavior: "FixedSize" | "Content" | "Window"): void;参数
- behavior
- 
				"FixedSize" | "Content" | "Window" 
指定 Word 如何使用"自动调整"功能重新调整指定表格的大小。
返回
void
注解
		autoFitWindow()
	  
	
		autoFormat(options)
	 
	将预定义外观应用于表格。
autoFormat(options?: Word.TableAutoFormatOptions): void;参数
- options
- Word.TableAutoFormatOptions
可选。 一个 对象,指定用于应用表格式的选项。
返回
void
注解
clear()
		convertToText(options)
	 
	将表格转换为文本。
convertToText(options?: Word.TableConvertToTextOptions): Word.Range;参数
- options
- Word.TableConvertToTextOptions
可选。 一个 对象,指定用于将表转换为文本的选项。
返回
一个 Range 对象,表示转换后的文本。
注解
delete()
		deleteColumns(columnIndex, columnCount)
	   
	删除特定的列。 此方法适用于一致的 table。
deleteColumns(columnIndex: number, columnCount?: number): void;参数
- columnIndex
- 
				number 
要删除的第一列。
- columnCount
- 
				number 
可选。 要删除的列数。 默认值 1。
返回
void
注解
		deleteRows(rowIndex, rowCount)
	   
	删除特定的行。
deleteRows(rowIndex: number, rowCount?: number): void;参数
- rowIndex
- 
				number 
要删除的第一行。
- rowCount
- 
				number 
可选。 要删除的行数。 默认值 1。
返回
void
注解
		distributeColumns()
	 
	
		getBorder(borderLocation)
	  
	获取指定边框的边框样式。
getBorder(borderLocation: Word.BorderLocation): Word.TableBorder;参数
- borderLocation
- Word.BorderLocation
边框位置。
返回
注解
示例
// 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" 
边框位置。
返回
注解
		getCell(rowIndex, cellIndex)
	   
	获取指定行和列处的表单元格。 
              ItemNotFound如果指定的表单元格不存在,则引发错误。
getCell(rowIndex: number, cellIndex: number): Word.TableCell;参数
- rowIndex
- 
				number 
行的索引。
- cellIndex
- 
				number 
行中单元格的索引。
返回
注解
示例
// 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)
	     
	获取指定行和列处的表单元格。 如果指定的表单元格不存在,则此方法将返回其属性设置为 true的对象isNullObject。 有关详细信息,请参阅 *OrNullObject 方法和属性。
getCellOrNullObject(rowIndex: number, cellIndex: number): Word.TableCell;参数
- rowIndex
- 
				number 
行的索引。
- cellIndex
- 
				number 
行中单元格的索引。
返回
注解
		getCellPadding(cellPaddingLocation)
	    
	获取单元格填充(以磅为单位)。
getCellPadding(cellPaddingLocation: Word.CellPaddingLocation): OfficeExtension.ClientResult<number>;参数
- cellPaddingLocation
- Word.CellPaddingLocation
单元格填充位置必须为 top、left、bottom 或 。right
返回
OfficeExtension.ClientResult<number>
注解
示例
// 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
返回
OfficeExtension.ClientResult<number>
注解
		getNext()
	 
	获取下一个表格。 如果此表是最后一个 ItemNotFound 表,则引发错误。
getNext(): Word.Table;返回
注解
		getNextOrNullObject()
	   
	获取下一个表格。 如果此表是最后一个表,则此方法将返回其属性设置为 true的对象isNullObject。 有关详细信息,请参阅 *OrNullObject 方法和属性。
getNextOrNullObject(): Word.Table;返回
注解
		getParagraphAfter()
	  
	获取 table 之后的 paragraph。 
              ItemNotFound如果表后没有段落,则引发错误。
getParagraphAfter(): Word.Paragraph;返回
注解
		getParagraphAfterOrNullObject()
	    
	获取 table 之后的 paragraph。 如果表后没有段落,则此方法将返回其属性设置为 true的对象isNullObject。 有关详细信息,请参阅 *OrNullObject 方法和属性。
getParagraphAfterOrNullObject(): Word.Paragraph;返回
注解
		getParagraphBefore()
	  
	获取 table 之前的 paragraph。 
              ItemNotFound如果表前没有段落,则引发错误。
getParagraphBefore(): Word.Paragraph;返回
注解
		getParagraphBeforeOrNullObject()
	    
	获取 table 之前的 paragraph。 如果表前没有段落,则此方法将返回其属性设置为 true的对象isNullObject。 有关详细信息,请参阅 *OrNullObject 方法和属性。
getParagraphBeforeOrNullObject(): Word.Paragraph;返回
注解
		getRange(rangeLocation)
	  
	获取包含此表格的范围,或包含此表格的开头或结尾的范围。
getRange(rangeLocation?: Word.RangeLocation.whole | Word.RangeLocation.start | Word.RangeLocation.end | Word.RangeLocation.after | "Whole" | "Start" | "End" | "After"): Word.Range;参数
可选。 范围位置必须为 whole、start、end 或 。after
返回
注解
		insertContentControl()
	  
	在表格中插入内容控件。
insertContentControl(): Word.ContentControl;返回
注解
		insertParagraph(paragraphText, insertLocation)
	   
	在指定位置插入段落。
insertParagraph(paragraphText: string, insertLocation: Word.InsertLocation.before | Word.InsertLocation.after | "Before" | "After"): Word.Paragraph;参数
- paragraphText
- 
				string 
要插入的段落文本。
返回
注解
		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 
表格的列数。
- values
- 
				string[][] 
可选的二维数组。 如果指定数组中的对应字符串,则填充单元格。
返回
注解
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 
行中最后一个单元格的索引。
返回
注解
		reapplyAutoFormat()
	  
	在调用 方法时,汇报具有预定义表格式设置的特征的autoFormat表。 默认的预定义格式为 TableFormatType.none。
reapplyAutoFormat(): void;返回
void
注解
		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; } 
可选。 用于搜索的选项。
返回
注解
		select(selectionMode)
	 
	选择表格或其开头或结尾位置,然后将 Word UI 导航到相应位置。
select(selectionMode?: Word.SelectionMode): void;参数
- selectionMode
- Word.SelectionMode
可选。 选择模式必须是 select、 start或 end。 
              select 为默认值。
返回
void
注解
		select(selectionMode)
	 
	选择表格或其开头或结尾位置,然后将 Word UI 导航到相应位置。
select(selectionMode?: "Select" | "Start" | "End"): void;参数
- selectionMode
- 
				"Select" | "Start" | "End" 
可选。 选择模式必须是 select、 start或 end。 
              select 为默认值。
返回
void
注解
set(properties, options)
同时设置对象的多个属性。 可以传递具有相应属性的纯对象,也可以传递同一类型的另一个 API 对象。
set(properties: Interfaces.TableUpdateData, options?: OfficeExtension.UpdateOptions): void;参数
- properties
- Word.Interfaces.TableUpdateData
一个 JavaScript 对象,其属性按同构方式构造为调用方法的对象的属性。
- options
- OfficeExtension.UpdateOptions
提供一个选项,用于在 properties 对象尝试设置任何只读属性时禁止显示错误。
返回
void
set(properties)
		setCellPadding(cellPaddingLocation, cellPadding)
	     
	设置单元格填充(以磅为单位)。
setCellPadding(cellPaddingLocation: Word.CellPaddingLocation, cellPadding: number): void;参数
- cellPaddingLocation
- Word.CellPaddingLocation
单元格填充位置必须为 top、left、bottom 或 。right
- cellPadding
- 
				number 
单元格填充。
返回
void
注解
		setCellPadding(cellPaddingLocation, cellPadding)
	     
	设置单元格填充(以磅为单位)。
setCellPadding(cellPaddingLocation: "Top" | "Left" | "Bottom" | "Right", cellPadding: number): void;参数
- cellPaddingLocation
- 
				"Top" | "Left" | "Bottom" | "Right" 
单元格填充位置必须为 top、left、bottom 或 。right
- cellPadding
- 
				number 
单元格填充。
返回
void
注解
sort(options)
对指定的表格进行排序。
sort(options?: Word.TableSortOptions): void;参数
- options
- Word.TableSortOptions
可选。 一个 对象,该对象指定用于对表进行排序的选项。
返回
void
注解
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;