跳到主要内容

GetCell

通过位置返回单元格。

语法

expression.GetCell(nRow, nCell);

expression - 表示 ApiTable 类的变量。

参数

名称必需/可选数据类型默认值描述
nRow必需number指定单元格所在的当前表格中的行位置。
nCell必需number当前表格中的单元格位置。

返回值

ApiTableCell | null

示例

此示例展示如何通过位置获取单元格。

// How to get cell from the table.

// Get the first table cell and add text to it.

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");