跳到主要内容

GetCell

通过位置返回单元格。

语法

expression.GetCell(rowIndex, cellIndex);

expression - 表示 ApiTable 类的变量。

参数

名称必需/可选数据类型默认值描述
rowIndex必需number当前表格中的行索引。
cellIndex必需number指定行中的单元格索引。

返回值

ApiTableCell

示例

通过行和列位置访问文档中的特定单元格。

// How do I retrieve a particular cell from a table in a document?

// Target an individual cell using its coordinates to write content in a document.

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