Skip to main content

Word.TableCell

Word.TableCell is an object type of the Word module (Office.word(iframe)). 10 methods.

Generated from the SDK type definitions

Word · 14 object types · 259 methods · namespace Word. This reference is generated from the API document artifact (sdk-api-doc.html) produced with the SDK build. Descriptions are the editor's API comments as published. Pin the SDK and Office versions together and regenerate when either changes.

Remarks

Methods

MethodDescription
getColumn()Returns the column index.
getParagraph(index)Returns the paragraph at the given index inside the cell.
getParagraphs()Returns all paragraphs in the cell, in order.
getRow()Returns the row index.
getTable()Returns the table this cell belongs to.
setBackgroundColor(color)Sets the cell background color.
setBorder(border)Sets the cell border.
setPadding(padding)Sets the inner padding of the cell.
setText(text)Replaces the text of the first paragraph in the cell with the given text.
setVerticalAlignment(align)Sets the vertical alignment of the cell.

Method details

getColumn()

Returns the column index.

getColumn(): Promise<number>;

Returns

Promise<number> - 0-based column index

getParagraph(index)

Returns the paragraph at the given index inside the cell. - Use the returned paragraph to read its text and edit its content and formatting.

getParagraph(index?: number): Promise<Paragraph>;

Parameters

NameTypeDescription
index (optional)number0-based paragraph index (default: 0)

Returns

Promise<Paragraph> - the paragraph, or null if none

getParagraphs()

Returns all paragraphs in the cell, in order.

getParagraphs(): Promise<Paragraph[]>;

Returns

Promise<Paragraph[]> - array of paragraphs inside the cell (empty array if the cell is empty)

getRow()

Returns the row index.

getRow(): Promise<number>;

Returns

Promise<number> - 0-based row index

getTable()

Returns the table this cell belongs to.

getTable(): Promise<Table>;

Returns

Promise<Table> - the table this cell belongs to

setBackgroundColor(color)

Sets the cell background color.

setBackgroundColor(color: string | null): Promise<void>;

Parameters

NameTypeDescription
colorstring | null"#RRGGBB" hex color; null/"" removes the background

Returns

Promise<void>

setBorder(border)

Sets the cell border.

setBorder(border: Border): Promise<void>;

Parameters

NameTypeDescription
borderBorderborder value

Returns

Promise<void>

setPadding(padding)

Sets the inner padding of the cell. - Only the specified sides are changed.

setPadding(padding: Padding): Promise<void>;

Parameters

NameTypeDescription
paddingPaddingpadding for the four sides

Returns

Promise<void>

setText(text)

Replaces the text of the first paragraph in the cell with the given text. - Only the first paragraph is changed; the other paragraphs of the cell are left as they are.

setText(text: string): Promise<void>;

Parameters

NameTypeDescription
textstringtext to set

Returns

Promise<void>

setVerticalAlignment(align)

Sets the vertical alignment of the cell.

setVerticalAlignment(align: CellVerticalAlign): Promise<void>;

Parameters

NameTypeDescription
alignCellVerticalAlign"top" | "center" | "bottom"

Returns

Promise<void>