Skip to main content

AddColumns

Adds the new columns to the current table.

Syntax​

expression.AddColumns(oCell, nCount, isBefore);

expression - A variable that represents an ApiTable class.

Parameters​

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

Returns​

ApiTable

Example​

Add extra columns to an existing table in a document.

// Insert several columns in a single call instead of adding them one by one in a document.

// Expand a table sideways by placing new columns at a chosen position in a document.

let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
doc.Push(table);
let cell = table.Cells[0][0];
cell.GetContent().GetElement(0).AddText("Two new columns were added after this cell.");
table.AddColumns(cell, 2, false);