跳到主要内容

AddColumn

Adds a new column to the current table.

Syntax

expression.AddColumn(oCell, isBefore);

expression - A variable that represents a ApiTable class.

Parameters

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

Returns

This method doesn't return any data.

Example

This example adds a new column to the table.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("We create a 2x2 table and add a new column, so that it becomes 3x2:");
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.AddColumn(table.GetRow(0).GetCell(1), true);
doc.Push(table);