Word.TableCell
Word.TableCell is an object type of the Word module (Office.word(iframe)). 10 methods.
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
- Module: Word ·
Office.word(iframe)· namespaceWord - Obtained from:
Paragraph.getParentTableCell(),Table.getCell(rowIndex, columnIndex),TableRow.getCell(columnIndex),TableRow.getCells() - Every method returns a
Promise; signatures use TypeScript notation.
Methods
| Method | Description |
|---|---|
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
| Name | Type | Description |
|---|---|---|
index (optional) | number | 0-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
| Name | Type | Description |
|---|---|---|
color | string | null | "#RRGGBB" hex color; null/"" removes the background |
Returns
Promise<void>
setBorder(border)
Sets the cell border.
setBorder(border: Border): Promise<void>;
Parameters
| Name | Type | Description |
|---|---|---|
border | Border | border 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
| Name | Type | Description |
|---|---|---|
padding | Padding | padding 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
| Name | Type | Description |
|---|---|---|
text | string | text to set |
Returns
Promise<void>
setVerticalAlignment(align)
Sets the vertical alignment of the cell.
setVerticalAlignment(align: CellVerticalAlign): Promise<void>;
Parameters
| Name | Type | Description |
|---|---|---|
align | CellVerticalAlign | "top" | "center" | "bottom" |
Returns
Promise<void>