Word.TableRow class

Represents a row in a Word document.

[ API set: WordApi 1.3 ]

Extends

Properties

cellCount

Gets the number of cells in the row. Read-only.

[ API set: WordApi 1.3 ]

cells

Gets cells. Read-only.

[ API set: WordApi 1.3 ]

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

font

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

[ API set: WordApi 1.3 ]

horizontalAlignment

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

[ API set: WordApi 1.3 ]

isHeader

Checks whether the row is a header row. Read-only. To set the number of header rows, use HeaderRowCount on the Table object.

[ API set: WordApi 1.3 ]

parentTable

Gets parent table. Read-only.

[ API set: WordApi 1.3 ]

preferredHeight

Gets and sets the preferred height of the row in points.

[ API set: WordApi 1.3 ]

rowIndex

Gets the index of the row in its parent table. 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 ]

values

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

[ API set: WordApi 1.3 ]

verticalAlignment

Gets and sets the vertical alignment of the cells in the row. The value can be 'Top', 'Center', or 'Bottom'.

[ API set: WordApi 1.3 ]

Methods

clear()

Clears the contents of the row.

[ API set: WordApi 1.3 ]

delete()

Deletes the entire row.

[ API set: WordApi 1.3 ]

getBorder(borderLocation)

Gets the border style of the cells in the row.

[ API set: WordApi 1.3 ]

getBorder(borderLocationString)

Gets the border style of the cells in the row.

[ API set: WordApi 1.3 ]

getCellPadding(cellPaddingLocation)

Gets cell padding in points.

[ API set: WordApi 1.3 ]

getCellPadding(cellPaddingLocationString)

Gets cell padding in points.

[ API set: WordApi 1.3 ]

getNext()

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

[ API set: WordApi 1.3 ]

getNextOrNullObject()

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

[ API set: WordApi 1.3 ]

insertRows(insertLocation, rowCount, values)

Inserts rows using this row as a template. If values are specified, inserts the values into the new rows.

[ API set: WordApi 1.3 ]

insertRows(insertLocationString, rowCount, values)

Inserts rows using this row as a template. If values are specified, inserts the values into the new rows.

[ 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.

load(propertyNames)

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

load(propertyNamesAndPaths)

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 row. The search results are a collection of range objects.

[ API set: WordApi 1.3 ]

select(selectionMode)

Selects the row and navigates the Word UI to it.

[ API set: WordApi 1.3 ]

select(selectionModeString)

Selects the row and navigates the Word UI to it.

[ API set: WordApi 1.3 ]

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

setCellPadding(cellPaddingLocation, cellPadding)

Sets cell padding in points.

[ API set: WordApi 1.3 ]

setCellPadding(cellPaddingLocationString, 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

cellCount

Gets the number of cells in the row. Read-only.

[ API set: WordApi 1.3 ]

readonly cellCount: number;

Property Value

number

cells

Gets cells. Read-only.

[ API set: WordApi 1.3 ]

readonly cells: Word.TableCellCollection;

Property Value

Word.TableCellCollection

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

RequestContext

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

horizontalAlignment

Gets and sets the horizontal alignment of every cell in the row. 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"

isHeader

Checks whether the row is a header row. Read-only. To set the number of header rows, use HeaderRowCount on the Table object.

[ API set: WordApi 1.3 ]

readonly isHeader: boolean;

Property Value

boolean

parentTable

Gets parent table. Read-only.

[ API set: WordApi 1.3 ]

readonly parentTable: Word.Table;

Property Value

Word.Table

preferredHeight

Gets and sets the preferred height of the row in points.

[ API set: WordApi 1.3 ]

preferredHeight: number;

Property Value

number

rowIndex

Gets the index of the row in its parent table. Read-only.

[ API set: WordApi 1.3 ]

readonly rowIndex: number;

Property Value

number

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

values

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

[ API set: WordApi 1.3 ]

values: string[][];

Property Value

string[][]

verticalAlignment

Gets and sets the vertical alignment of the cells in the row. 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"

Method Details

clear()

Clears the contents of the row.

[ API set: WordApi 1.3 ]

clear(): void;

Returns

void

delete()

Deletes the entire row.

[ API set: WordApi 1.3 ]

delete(): void;

Returns

void

getBorder(borderLocation)

Gets the border style of the cells in the row.

[ API set: WordApi 1.3 ]

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

Parameters

borderLocation
Word.BorderLocation

Required. The border location.

Returns

getBorder(borderLocationString)

Gets the border style of the cells in the row.

[ API set: WordApi 1.3 ]

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

Parameters

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

Required. The border location.

Returns

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>

getCellPadding(cellPaddingLocationString)

Gets cell padding in points.

[ API set: WordApi 1.3 ]

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

Parameters

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

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

Returns

OfficeExtension.ClientResult<number>

getNext()

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

[ API set: WordApi 1.3 ]

getNext(): Word.TableRow;

Returns

Word.TableRow

getNextOrNullObject()

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

[ API set: WordApi 1.3 ]

getNextOrNullObject(): Word.TableRow;

Returns

Word.TableRow

insertRows(insertLocation, rowCount, values)

Inserts rows using this row as a template. If values are specified, inserts the values into the new rows.

[ API set: WordApi 1.3 ]

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

Parameters

insertLocation
Word.InsertLocation

Required. Where the new rows should be inserted, relative to the current row. It can be 'Before' or 'After'.

rowCount
number

Required. Number of rows to add

values
string[][]

Optional. Strings to insert in the new rows, specified as a 2D array. The number of cells in each row must not exceed the number of cells in the existing row.

Returns

Word.TableRowCollection

insertRows(insertLocationString, rowCount, values)

Inserts rows using this row as a template. If values are specified, inserts the values into the new rows.

[ API set: WordApi 1.3 ]

insertRows(insertLocationString: "Before" | "After" | "Start" | "End" | "Replace", rowCount: number, values?: string[][]): Word.TableRowCollection;

Parameters

insertLocationString
"Before" | "After" | "Start" | "End" | "Replace"

Required. Where the new rows should be inserted, relative to the current row. It can be 'Before' or 'After'.

rowCount
number

Required. Number of rows to add

values
string[][]

Optional. Strings to insert in the new rows, specified as a 2D array. The number of cells in each row must not exceed the number of cells in the existing row.

Returns

Word.TableRowCollection

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?: Word.Interfaces.TableRowLoadOptions): Word.TableRow;

Parameters

option
Word.Interfaces.TableRowLoadOptions

Returns

Word.TableRow

Remarks

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

load(option?: string | string[]): Word.TableRow - Where option is a comma-delimited string or an array of strings that specify the properties to load.

load(option?: { select?: string; expand?: string; }): Word.TableRow - 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.TableRow - 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.

load(propertyNames)

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

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

Parameters

propertyNames
string | string[]

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

Returns

Word.TableRow

load(propertyNamesAndPaths)

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

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

Parameters

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

Where propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

Word.TableRow

search(searchText, searchOptions)

Performs a search with the specified SearchOptions on the scope of the row. 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

Word.RangeCollection

select(selectionMode)

Selects the row 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

select(selectionModeString)

Selects the row and navigates the Word UI to it.

[ API set: WordApi 1.3 ]

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

Parameters

selectionModeString
"Select" | "Start" | "End"

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

Returns

void

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

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

Parameters

properties
Interfaces.TableRowUpdateData

A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

Provides an option to suppress errors if the properties object tries to set any read-only properties.

Returns

void

Remarks

This method has the following additional signature:

set(properties: Word.TableRow): void

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

set(properties: Word.TableRow): void;

Parameters

properties
Word.TableRow

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

setCellPadding(cellPaddingLocationString, cellPadding)

Sets cell padding in points.

[ API set: WordApi 1.3 ]

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

Parameters

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

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

cellPadding
number

Required. The cell padding.

Returns

void

toJSON()

toJSON(): Word.Interfaces.TableRowData;

Returns

Word.Interfaces.TableRowData

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.TableRow;

Returns

Word.TableRow

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.TableRow;

Returns

Word.TableRow