跳到主要内容

GetCell

按当前行中的位置返回单元格。

语法

expression.GetCell(cellIndex);

expression - 表示 ApiTableRow 类的变量。

参数

名称必需/可选数据类型默认值描述
cellIndex必需number表格行中从零开始的单元格索引。

返回值

ApiTableCell

示例

从 PDF 中的表格行访问特定单元格。

// How do I retrieve a single cell from a row in a PDF?

// Get any cell you want from a table row in a PDF.

const doc = Api.GetDocument();
const page = doc.GetPage(0);

const table = Api.CreateTable(2, 4);
const row = table.GetRow(0);
const cell = row.GetCell(0);
const content = cell.GetContent();
const paragraph = Api.CreateParagraph();
paragraph.AddText("This is a sample text in the cell of the first row.");
content.Push(paragraph);

page.AddObject(table);