Skip to main content

TableCellCollection Class

A collection of the TableCell objects.

Declaration

export class TableCellCollection extends TableBaseCollection<TableCell>

Remarks

An object of this class can be accessed by the cells property.

Inherited Members

Methods

insert(index) Method

Inserts a cell to the right or left of the specified cell.

Declaration

insert(
    index: number,
    toRight?: boolean
): TableCell

Parameters

Name Type Description
index number

The index of the cell relative to which to insert a cell.

toRight boolean

true to insert a cell to the right of the specified cell; false to insert a cell to the left of the specified cell.

Returns

Type Description
TableCell

The newly inserted table cell.

Remarks

Note

The newly inserted cell copies appearance settings from the cell whose index you passed as the index parameter.

The following code snippet inserts a new cell to the right of the first table cell:

const subDocument = richEdit.selection.activeSubDocument;
const table = subDocument.tables.getByIndex(0);
table.rows.getByIndex(0).cells.insert(0, true);

remove(index) Method

Removes a cell with the specified index from the row.

Declaration

remove(
    index: number
): void

Parameters

Name Type Description
index number

A cell index in the collection.

Remarks

Note

Once you remove all cells from a row, the table removes the row from the row collection.

The following code snippet removes the last cell in the first row:

const subDocument = richEdit.selection.activeSubDocument;
const table = subDocument.tables.getByIndex(0);
const firstRow = table.rows.getByIndex(0);
firstRow.cells.remove(firstRow.cells.count-1);