跳到主要内容

GetCell

Returns a cell by its position.

Syntax

expression.GetCell(nRow, nCell);

expression - A variable that represents a ApiTable class.

Parameters

NameRequired/OptionalData typeDefaultDescription
nRowRequirednumberThe row position in the current table where the specified cell is placed.
nCellRequirednumberThe cell position in the current table.

Returns

ApiTableCell | null

Example

This example shows how to get a cell by its position.

let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
doc.Push(table);
let cell = table.GetCell(0, 0);
cell.GetContent().GetElement(0).AddText("Cell #1");