跳到主要内容

AddRow

Adds a new row to the current table.

Syntax

expression.AddRow(oCell, isBefore);

expression - A variable that represents a ApiTable class.

Parameters

NameRequired/OptionalData typeDefaultDescription
oCellOptionalApiTableCellThe cell after which a new row will be added. If not specified, a new row will be added at the end of the table.
isBeforeOptionalbooleanfalseAdds a new row before (false) or after (true) the specified cell. If no cell is specified, then this parameter will be ignored.

Returns

ApiTableRow

Example

This example adds a new row to the table.

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);