跳到主要内容

AddRow

向当前表格添加新行。

语法

expression.AddRow(oCell, isBefore);

expression - 表示 ApiTable 类的变量。

参数

名称必需/可选数据类型默认值描述
oCell可选ApiTableCell将在该单元格之后添加新行。如果未指定,将在表格末尾添加新行。
isBefore可选booleanfalse在指定单元格之前(false)或之后(true)添加新行。如果未指定单元格,则将忽略此参数。

返回值

ApiTableRow

示例

此示例向表格添加新行。

// How to add row to the table.

// Get row cell and add it as row.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("We create a 2x2 table and add a new row, so that it becomes 2x3:");
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(2, 2);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
table.AddRow(table.GetRow(1).GetCell(0), true);
doc.Push(table);