跳到主要内容

GetCell

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

语法

expression.GetCell(nPos);

expression - 表示 ApiTableRow 类的变量。

参数

名称必需/可选数据类型默认值描述
nPos必需number表格行中的单元格位置。

返回值

ApiTableCell

示例

此示例演示如何按行中的位置获取单元格。

// How to return a cell using its row index.

// Create a table, get its row and get a cell from this row.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(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);

slide.RemoveAllObjects();
slide.AddObject(table);