跳到主要内容

AddColumns

向当前表格添加新列。

语法

expression.AddColumns(nCount, isBefore);

expression - 表示 ApiTableCell 类的变量。

参数

名称必需/可选数据类型默认值描述
nCount必需Number要添加的列数。
isBefore可选booleanfalse指定新列是添加在当前单元格之前还是之后。

返回值

ApiTable | null

示例

在文档中表格的现有单元格旁边插入附加列。

// How do I add more columns beside a specific cell in a table in a document?

// Expand a table horizontally by appending columns after a chosen cell 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);
table.GetCell(0, 0).GetContent().GetElement(0).AddText("Two new columns were added after this cell.");
table.GetCell(0, 0).AddColumns(2, false);