GetCell
按当前行中的位置返回单元格。
语法
expression.GetCell(nPos);
expression - 表示 ApiTableRow 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| nPos | 必需 | number | 表格行中的单元格位置。 |
返回值
示例
此示例演示如何按行中的位置获取单元格。
// 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);