Word.Table class

Represents a table in a Word document.

[ API set: WordApi 1.3 ]

Extends
OfficeExtension.ClientObject

Properties

alignment

Gets or sets the alignment of the table against the page column. The value can be 'Left', 'Centered', or 'Right'.

[ API set: WordApi 1.3 ]

font

Gets the font. Use this to get and set font name, size, color, and other properties. Read-only.

[ API set: WordApi 1.3 ]

headerRowCount

Gets and sets the number of header rows.

[ API set: WordApi 1.3 ]

horizontalAlignment

Gets and sets the horizontal alignment of every cell in the table. The value can be 'Left', 'Centered', 'Right', or 'Justified'.

[ API set: WordApi 1.3 ]

isUniform

Indicates whether all of the table rows are uniform. Read-only.

[ API set: WordApi 1.3 ]

nestingLevel

Gets the nesting level of the table. Top-level tables have level 1. Read-only.

[ API set: WordApi 1.3 ]

parentBody

Gets the parent body of the table. Read-only.

[ API set: WordApi 1.3 ]

parentContentControl

Gets the content control that contains the table. Throws if there isn't a parent content control. Read-only.

[ API set: WordApi 1.3 ]

parentContentControlOrNullObject

Gets the content control that contains the table. Returns a null object if there isn't a parent content control. Read-only.

[ API set: WordApi 1.3 ]

parentTable

Gets the table that contains this table. Throws if it is not contained in a table. Read-only.

[ API set: WordApi 1.3 ]

parentTableCell

Gets the table cell that contains this table. Throws if it is not contained in a table cell. Read-only.

[ API set: WordApi 1.3 ]

parentTableCellOrNullObject

Gets the table cell that contains this table. Returns a null object if it is not contained in a table cell. Read-only.

[ API set: WordApi 1.3 ]

parentTableOrNullObject

Gets the table that contains this table. Returns a null object if it is not contained in a table. Read-only.

[ API set: WordApi 1.3 ]

rowCount

Gets the number of rows in the table. Read-only.

[ API set: WordApi 1.3 ]

rows

Gets all of the table rows. Read-only.

[ API set: WordApi 1.3 ]

shadingColor

Gets and sets the shading color. Color is specified in "#RRGGBB" format or by using the color name.

[ API set: WordApi 1.3 ]

style

Gets or sets the style name for the table. Use this property for custom styles and localized style names. To use the built-in styles that are portable between locales, see the "styleBuiltIn" property.

[ API set: WordApi 1.3 ]

styleBandedColumns

Gets and sets whether the table has banded columns.

[ API set: WordApi 1.3 ]

styleBandedRows

Gets and sets whether the table has banded rows.

[ API set: WordApi 1.3 ]

styleBuiltIn

Gets or sets the built-in style name for the table. Use this property for built-in styles that are portable between locales. To use custom styles or localized style names, see the "style" property.

[ API set: WordApi 1.3 ]

styleFirstColumn

Gets and sets whether the table has a first column with a special style.

[ API set: WordApi 1.3 ]

styleLastColumn

Gets and sets whether the table has a last column with a special style.

[ API set: WordApi 1.3 ]

styleTotalRow

Gets and sets whether the table has a total (last) row with a special style.

[ API set: WordApi 1.3 ]

tables

Gets the child tables nested one level deeper. Read-only.

[ API set: WordApi 1.3 ]

values

Gets and sets the text values in the table, as a 2D Javascript array.

[ API set: WordApi 1.3 ]

verticalAlignment

Gets and sets the vertical alignment of every cell in the table. The value can be 'Top', 'Center', or 'Bottom'.

[ API set: WordApi 1.3 ]

width

Gets and sets the width of the table in points.

[ API set: WordApi 1.3 ]

Methods

addColumns(insertLocation, columnCount, values)

Adds columns to the start or end of the table, using the first or last existing column as a template. This is applicable to uniform tables. The string values, if specified, are set in the newly inserted rows.

[ API set: WordApi 1.3 ]

addRows(insertLocation, rowCount, values)

Adds rows to the start or end of the table, using the first or last existing row as a template. The string values, if specified, are set in the newly inserted rows.

[ API set: WordApi 1.3 ]

autoFitWindow()

Autofits the table columns to the width of the window.

[ API set: WordApi 1.3 ]

clear()

Clears the contents of the table.

[ API set: WordApi 1.3 ]

delete()

Deletes the entire table.

[ API set: WordApi 1.3 ]

deleteColumns(columnIndex, columnCount)

Deletes specific columns. This is applicable to uniform tables.

[ API set: WordApi 1.3 ]

deleteRows(rowIndex, rowCount)

Deletes specific rows.

[ API set: WordApi 1.3 ]

distributeColumns()

Distributes the column widths evenly. This is applicable to uniform tables.

[ API set: WordApi 1.3 ]

getBorder(borderLocation)

Gets the border style for the specified border.

[ API set: WordApi 1.3 ]

getCell(rowIndex, cellIndex)

Gets the table cell at a specified row and column. Throws if the specified table cell does not exist.

[ API set: WordApi 1.3 ]

getCellOrNullObject(rowIndex, cellIndex)

Gets the table cell at a specified row and column. Returns a null object if the specified table cell does not exist.

[ API set: WordApi 1.3 ]

getCellPadding(cellPaddingLocation)

Gets cell padding in points.

[ API set: WordApi 1.3 ]

getNext()

Gets the next table. Throws if this table is the last one.

[ API set: WordApi 1.3 ]

getNextOrNullObject()

Gets the next table. Returns a null object if this table is the last one.

[ API set: WordApi 1.3 ]

getParagraphAfter()

Gets the paragraph after the table. Throws if there isn't a paragraph after the table.

[ API set: WordApi 1.3 ]

getParagraphAfterOrNullObject()

Gets the paragraph after the table. Returns a null object if there isn't a paragraph after the table.

[ API set: WordApi 1.3 ]

getParagraphBefore()

Gets the paragraph before the table. Throws if there isn't a paragraph before the table.

[ API set: WordApi 1.3 ]

getParagraphBeforeOrNullObject()

Gets the paragraph before the table. Returns a null object if there isn't a paragraph before the table.

[ API set: WordApi 1.3 ]

getRange(rangeLocation)

Gets the range that contains this table, or the range at the start or end of the table.

[ API set: WordApi 1.3 ]

insertContentControl()

Inserts a content control on the table.

[ API set: WordApi 1.3 ]

insertParagraph(paragraphText, insertLocation)

Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'.

[ API set: WordApi 1.3 ]

insertTable(rowCount, columnCount, insertLocation, values)

Inserts a table with the specified number of rows and columns. The insertLocation value can be 'Before' or 'After'.

[ API set: WordApi 1.3 ]

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

search(searchText, searchOptions)

Performs a search with the specified SearchOptions on the scope of the table object. The search results are a collection of range objects.

[ API set: WordApi 1.3 ]

select(selectionMode)

Selects the table, or the position at the start or end of the table, and navigates the Word UI to it.

[ API set: WordApi 1.3 ]

setCellPadding(cellPaddingLocation, cellPadding)

Sets cell padding in points.

[ API set: WordApi 1.3 ]

toJSON()
track()

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you are using this object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created.

untrack()

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect.

Property Details

alignment

Gets or sets the alignment of the table against the page column. The value can be 'Left', 'Centered', or 'Right'.

[ API set: WordApi 1.3 ]

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

font

Gets the font. Use this to get and set font name, size, color, and other properties. Read-only.

[ API set: WordApi 1.3 ]

readonly font: Word.Font;
Property Value

headerRowCount

Gets and sets the number of header rows.

[ API set: WordApi 1.3 ]

headerRowCount: number;
Property Value
number

horizontalAlignment

Gets and sets the horizontal alignment of every cell in the table. The value can be 'Left', 'Centered', 'Right', or 'Justified'.

[ API set: WordApi 1.3 ]

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

isUniform

Indicates whether all of the table rows are uniform. Read-only.

[ API set: WordApi 1.3 ]

readonly isUniform: boolean;
Property Value
boolean

nestingLevel

Gets the nesting level of the table. Top-level tables have level 1. Read-only.

[ API set: WordApi 1.3 ]

readonly nestingLevel: number;
Property Value
number

parentBody

Gets the parent body of the table. Read-only.

[ API set: WordApi 1.3 ]

readonly parentBody: Word.Body;
Property Value
Word.Body

parentContentControl

Gets the content control that contains the table. Throws if there isn't a parent content control. Read-only.

[ API set: WordApi 1.3 ]

readonly parentContentControl: Word.ContentControl;
Property Value

parentContentControlOrNullObject

Gets the content control that contains the table. Returns a null object if there isn't a parent content control. Read-only.

[ API set: WordApi 1.3 ]

readonly parentContentControlOrNullObject: Word.ContentControl;
Property Value

parentTable

Gets the table that contains this table. Throws if it is not contained in a table. Read-only.

[ API set: WordApi 1.3 ]

readonly parentTable: Word.Table;
Property Value
Word.Table

parentTableCell

Gets the table cell that contains this table. Throws if it is not contained in a table cell. Read-only.

[ API set: WordApi 1.3 ]

readonly parentTableCell: Word.TableCell;
Property Value
Word.TableCell

parentTableCellOrNullObject

Gets the table cell that contains this table. Returns a null object if it is not contained in a table cell. Read-only.

[ API set: WordApi 1.3 ]

readonly parentTableCellOrNullObject: Word.TableCell;
Property Value
Word.TableCell

parentTableOrNullObject

Gets the table that contains this table. Returns a null object if it is not contained in a table. Read-only.

[ API set: WordApi 1.3 ]

readonly parentTableOrNullObject: Word.Table;
Property Value
Word.Table

rowCount

Gets the number of rows in the table. Read-only.

[ API set: WordApi 1.3 ]

readonly rowCount: number;
Property Value
number

rows

Gets all of the table rows. Read-only.

[ API set: WordApi 1.3 ]

readonly rows: Word.TableRowCollection;
Property Value
Word.TableRowCollection

shadingColor

Gets and sets the shading color. Color is specified in "#RRGGBB" format or by using the color name.

[ API set: WordApi 1.3 ]

shadingColor: string;
Property Value
string

style

Gets or sets the style name for the table. Use this property for custom styles and localized style names. To use the built-in styles that are portable between locales, see the "styleBuiltIn" property.

[ API set: WordApi 1.3 ]

style: string;
Property Value
string

styleBandedColumns

Gets and sets whether the table has banded columns.

[ API set: WordApi 1.3 ]

styleBandedColumns: boolean;
Property Value
boolean

styleBandedRows

Gets and sets whether the table has banded rows.

[ API set: WordApi 1.3 ]

styleBandedRows: boolean;
Property Value
boolean

styleBuiltIn

Gets or sets the built-in style name for the table. Use this property for built-in styles that are portable between locales. To use custom styles or localized style names, see the "style" property.

[ API set: WordApi 1.3 ]

styleBuiltIn: Word.Style | "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";
Property Value
Word.Style | "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

Gets and sets whether the table has a first column with a special style.

[ API set: WordApi 1.3 ]

styleFirstColumn: boolean;
Property Value
boolean

styleLastColumn

Gets and sets whether the table has a last column with a special style.

[ API set: WordApi 1.3 ]

styleLastColumn: boolean;
Property Value
boolean

styleTotalRow

Gets and sets whether the table has a total (last) row with a special style.

[ API set: WordApi 1.3 ]

styleTotalRow: boolean;
Property Value
boolean

tables

Gets the child tables nested one level deeper. Read-only.

[ API set: WordApi 1.3 ]

readonly tables: Word.TableCollection;
Property Value
Word.TableCollection

values

Gets and sets the text values in the table, as a 2D Javascript array.

[ API set: WordApi 1.3 ]

values: string[][];
Property Value
string[][]

verticalAlignment

Gets and sets the vertical alignment of every cell in the table. The value can be 'Top', 'Center', or 'Bottom'.

[ API set: WordApi 1.3 ]

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

width

Gets and sets the width of the table in points.

[ API set: WordApi 1.3 ]

width: number;
Property Value
number

Method Details

addColumns(insertLocation, columnCount, values)

Adds columns to the start or end of the table, using the first or last existing column as a template. This is applicable to uniform tables. The string values, if specified, are set in the newly inserted rows.

[ API set: WordApi 1.3 ]

addColumns(insertLocation: Word.InsertLocation, columnCount: number, values?: string[][]): void;
Parameters
insertLocation
Word.InsertLocation

Required. It can be 'Start' or 'End', corresponding to the appropriate side of the table.

columnCount
number

Required. Number of columns to add.

values
string[][]

Optional 2D array. Cells are filled if the corresponding strings are specified in the array.

Returns
void

addRows(insertLocation, rowCount, values)

Adds rows to the start or end of the table, using the first or last existing row as a template. The string values, if specified, are set in the newly inserted rows.

[ API set: WordApi 1.3 ]

addRows(insertLocation: Word.InsertLocation, rowCount: number, values?: string[][]): Word.TableRowCollection;
Parameters
insertLocation
Word.InsertLocation

Required. It can be 'Start' or 'End'.

rowCount
number

Required. Number of rows to add.

values
string[][]

Optional 2D array. Cells are filled if the corresponding strings are specified in the array.

Returns
Word.TableRowCollection

autoFitWindow()

Autofits the table columns to the width of the window.

[ API set: WordApi 1.3 ]

autoFitWindow(): void;
Returns
void

clear()

Clears the contents of the table.

[ API set: WordApi 1.3 ]

clear(): void;
Returns
void

delete()

Deletes the entire table.

[ API set: WordApi 1.3 ]

delete(): void;
Returns
void

deleteColumns(columnIndex, columnCount)

Deletes specific columns. This is applicable to uniform tables.

[ API set: WordApi 1.3 ]

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

Required. The first column to delete.

columnCount
number

Optional. The number of columns to delete. Default 1.

Returns
void

deleteRows(rowIndex, rowCount)

Deletes specific rows.

[ API set: WordApi 1.3 ]

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

Required. The first row to delete.

rowCount
number

Optional. The number of rows to delete. Default 1.

Returns
void

distributeColumns()

Distributes the column widths evenly. This is applicable to uniform tables.

[ API set: WordApi 1.3 ]

distributeColumns(): void;
Returns
void

getBorder(borderLocation)

Gets the border style for the specified border.

[ API set: WordApi 1.3 ]

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

Required. The border location.

Returns

getCell(rowIndex, cellIndex)

Gets the table cell at a specified row and column. Throws if the specified table cell does not exist.

[ API set: WordApi 1.3 ]

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

Required. The index of the row.

cellIndex
number

Required. The index of the cell in the row.

Returns
Word.TableCell

Examples

await Word.run(async (context) => {
    let firstCell = context.document.body.tables.getFirst().getCell(0, 0).body;
    firstCell.load("text");

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

getCellOrNullObject(rowIndex, cellIndex)

Gets the table cell at a specified row and column. Returns a null object if the specified table cell does not exist.

[ API set: WordApi 1.3 ]

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

Required. The index of the row.

cellIndex
number

Required. The index of the cell in the row.

Returns
Word.TableCell

getCellPadding(cellPaddingLocation)

Gets cell padding in points.

[ API set: WordApi 1.3 ]

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

Required. The cell padding location can be 'Top', 'Left', 'Bottom', or 'Right'.

Returns
OfficeExtension.ClientResult<number>

getNext()

Gets the next table. Throws if this table is the last one.

[ API set: WordApi 1.3 ]

getNext(): Word.Table;
Returns
Word.Table

getNextOrNullObject()

Gets the next table. Returns a null object if this table is the last one.

[ API set: WordApi 1.3 ]

getNextOrNullObject(): Word.Table;
Returns
Word.Table

getParagraphAfter()

Gets the paragraph after the table. Throws if there isn't a paragraph after the table.

[ API set: WordApi 1.3 ]

getParagraphAfter(): Word.Paragraph;
Returns
Word.Paragraph

getParagraphAfterOrNullObject()

Gets the paragraph after the table. Returns a null object if there isn't a paragraph after the table.

[ API set: WordApi 1.3 ]

getParagraphAfterOrNullObject(): Word.Paragraph;
Returns
Word.Paragraph

getParagraphBefore()

Gets the paragraph before the table. Throws if there isn't a paragraph before the table.

[ API set: WordApi 1.3 ]

getParagraphBefore(): Word.Paragraph;
Returns
Word.Paragraph

getParagraphBeforeOrNullObject()

Gets the paragraph before the table. Returns a null object if there isn't a paragraph before the table.

[ API set: WordApi 1.3 ]

getParagraphBeforeOrNullObject(): Word.Paragraph;
Returns
Word.Paragraph

getRange(rangeLocation)

Gets the range that contains this table, or the range at the start or end of the table.

[ API set: WordApi 1.3 ]

getRange(rangeLocation?: Word.RangeLocation): Word.Range;
Parameters
rangeLocation
Word.RangeLocation

Optional. The range location can be 'Whole', 'Start', 'End', or 'After'.

Returns
Word.Range

insertContentControl()

Inserts a content control on the table.

[ API set: WordApi 1.3 ]

insertContentControl(): Word.ContentControl;
Returns

insertParagraph(paragraphText, insertLocation)

Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'.

[ API set: WordApi 1.3 ]

insertParagraph(paragraphText: string, insertLocation: Word.InsertLocation): Word.Paragraph;
Parameters
paragraphText
string

Required. The paragraph text to be inserted.

insertLocation
Word.InsertLocation

Required. The value can be 'Before' or 'After'.

Returns
Word.Paragraph

insertTable(rowCount, columnCount, insertLocation, values)

Inserts a table with the specified number of rows and columns. The insertLocation value can be 'Before' or 'After'.

[ API set: WordApi 1.3 ]

insertTable(rowCount: number, columnCount: number, insertLocation: Word.InsertLocation, values?: string[][]): Word.Table;
Parameters
rowCount
number

Required. The number of rows in the table.

columnCount
number

Required. The number of columns in the table.

insertLocation
Word.InsertLocation

Required. The value can be 'Before' or 'After'.

values
string[][]

Optional 2D array. Cells are filled if the corresponding strings are specified in the array.

Returns
Word.Table

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

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

A comma-delimited string or an array of strings that specify the properties to load.

Returns
Word.Table
Remarks

In addition to this signature, this method has the following signatures:

load(option?: { select?: string; expand?: string; }): Word.Table - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load.

load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Table - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items.

search(searchText, searchOptions)

Performs a search with the specified SearchOptions on the scope of the table object. The search results are a collection of range objects.

[ API set: WordApi 1.3 ]

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

Required. The search text.

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

Optional. Options for the search.

Returns

select(selectionMode)

Selects the table, or the position at the start or end of the table, and navigates the Word UI to it.

[ API set: WordApi 1.3 ]

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

Optional. The selection mode can be 'Select', 'Start', or 'End'. 'Select' is the default.

Returns
void

setCellPadding(cellPaddingLocation, cellPadding)

Sets cell padding in points.

[ API set: WordApi 1.3 ]

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

Required. The cell padding location can be 'Top', 'Left', 'Bottom', or 'Right'.

cellPadding
number

Required. The cell padding.

Returns
void

toJSON()

toJSON(): Word.Interfaces.TableData;
Returns
Word.Interfaces.TableData

track()

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you are using this object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created.

track(): Word.Table;
Returns
Word.Table

untrack()

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect.

untrack(): Word.Table;
Returns
Word.Table