跳到主要内容

AddRow

向当前表格添加新行。

语法

expression.AddRow(referenceCell, isBefore);

expression - 表示 ApiTable 类的变量。

参数

名称必需/可选数据类型默认值描述
referenceCell可选ApiTableCell用作插入参考的单元格。
isBefore可选booleanfalse在指定单元格之前或之后添加新行。如果未指定单元格,则此参数将被忽略。

返回值

ApiTableRow

示例

在 PDF 中向表格插入新行

// Can I add more rows to an existing table in a PDF?

// Attach a row at a specific position within a table in a PDF

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

const table = Api.CreateTable(2, 4);
table.AddRow(1, true);
const row = table.GetRow(1);
const cell = row.GetCell(0);
const content = cell.GetContent();
const paragraph = Api.CreateParagraph();
paragraph.AddText("New row was added here.");
content.Push(paragraph);

page.AddObject(table);