跳到主要内容

AddRows

向当前表格添加新行。

语法​

expression.AddRows(nCount, isBefore);

expression - 表示 ApiTableRow 类的变量。

参数​

名称必需/可选数据类型默认值描述
nCount必需Number要添加的行数。
isBefore可选booleanfalse指定行是添加在当前行之前还是之后。

返回值​

ApiTable | null

示例​

在演示文稿中从某一行向表格添加新行。

// Useful for adding rows after a specific row.

// Insert two new rows after the first row.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
const table = Api.CreateTable(2, 3);
const row = table.GetRow(0);
const para = Api.CreateParagraph();
para.AddText("First row")
row.GetCell(0).GetContent().Push(para);
row.AddRows(2, false);
slide.RemoveAllObjects();
slide.AddObject(table);