Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TableCell Class

Defines a table cell in the document.

#Declaration

TypeScript
export class TableCell extends TableElementBase

#Remarks

var table = richEdit.document.tables.getByIndex(0);
var cell = table.rows.getByIndex(0).cells.getByIndex(0);
var text = richEdit.document.subDocuments.main.getText(cell.interval)

#Properties

#backgroundColor Property

Specifies the cell’s background color.

#Declaration

TypeScript
get backgroundColor(): string
set backgroundColor(value: string)

#Property Value

Type Description
string

The cell’s background color.

#Remarks

The backgroundColor property allows you to obtain and change the cell’s background color.

Note

A cell’s background (TableCell.backgroundColor) overlaps the table’s background (Table.backgroundColor).

#borders Property

Specifies a table’s border settings.

#Declaration

TypeScript
get borders(): TableCellBorders
set borders(value: ITableCellBorders)

#Property Value

Type Description
TableCellBorders

Cell border settings.

#Remarks

Specify the borders property to configure a cell’s border settings.

#characterProperties Property

Specifies formatting settings of characters in the cell.

#Declaration

TypeScript
get characterProperties(): CharacterProperties
set characterProperties(value: ICharacterProperties)

#Property Value

Type Description
CharacterProperties

Formatting settings of cell characters.

#Remarks

Use the characterProperties property to access and customize the formatting settings of cell characters.

js
const subDocument = richEdit.selection.activeSubDocument;
const table = subDocument.tables.getByIndex(0);
cell = table.rows.getByIndex(0).cells.getByIndex(0);
cell.characterProperties = { bold: true, underline: true };

#contentHorizontalAlignment Property

Specifies the horizontal alignment of a cell’s content.

#Declaration

TypeScript
get contentHorizontalAlignment(): TableContentHorizontalAlignment | null
set contentHorizontalAlignment(value: TableContentHorizontalAlignment)

#Property Value

Type Description
TableContentHorizontalAlignment

An enumeration value.

#Remarks

Use the contentHorizontalAlignment property to horizontally align content in a particular cell.

Note

A cell’s contentHorizontalAlignment property takes priority over the table’s contentHorizontalAlignment property.

#contentVerticalAlignment Property

Specifies the vertical alignment of a cell’s content.

#Declaration

TypeScript
get contentVerticalAlignment(): TableContentVerticalAlignment
set contentVerticalAlignment(value: TableContentVerticalAlignment)

#Property Value

Type Description
TableContentVerticalAlignment

An enumeration value.

#Remarks

Use the contentVerticalAlignment property to horizontally align content in a particular cell.

Note

A cell’s contentVerticalAlignment property takes priority over the table’s contentVerticalAlignment property.

#index Property

Gets an index of the cell in a table row.

#Declaration

TypeScript
get index(): number

#Property Value

Type Description
number

The cell index.

#Remarks

Use the index to access the corresponding cell by the TableCellCollection.getByIndex method.

var table = richEdit.document.tables.getByIndex(0);
var cell = table.rows.getByIndex(0).cells.getByIndex(0);
var text = richEdit.document.subDocuments.main.getText(cell.interval)

#interval Property

Gets the text buffer interval occupied by the current table cell element.

#Declaration

TypeScript
get interval(): Interval

#Property Value

Type Description
Interval

An object that contains the interval settings.

#Remarks

var table = richEdit.document.tables.getByIndex(0);
var cell = table.rows.getByIndex(0).cells.getByIndex(0);
var text = richEdit.document.subDocuments.main.getText(cell.interval)

#margins Property

Specifies the cell’s margin settings.

#Declaration

TypeScript
get margins(): Margins
set margins(value: IMargins)

#Property Value

Type Description
Margins

An object that contains margin settings.

#Remarks

Use the margins property to access and customize cell margins.

Note

A cell’s margins property takes priority over the table’s cellMargins property.

#parentRow Property

Returns the row that contains the current cell.

#Declaration

TypeScript
get parentRow(): TableRow

#Property Value

Type Description
TableRow

The row that contains the current cell.

#width Property

Specifies the cell’s width settings.

#Declaration

TypeScript
get width(): TableWidth
set width(value: TableWidth)

#Property Value

Type Description
TableWidth

An object that contains width settings.

#Remarks

Use the Table.width or TableCell.width property to specify the table or cell width.

#Methods

#split(columnCount, rowCount) Method

Splits the cell into multiple smaller cells.

#Declaration

TypeScript
split(
    columnCount: number,
    rowCount: number
): void

#Parameters

Name Type Description
columnCount number

The number of columns in the result cell range.

rowCount number

The number of rows in the result cell range.

#Remarks

Once you split a cell, its content moves to the first cell in the resulting cell range. All cells in the result range have the same appearance settings as the initial cell.

The following code snippet splits the first cell into 6 cells (3 columns and 2 rows):

js
const subDocument = richEdit.selection.activeSubDocument;
const table = subDocument.tables.getByIndex(0);
cell.split(3, 2);