跳到主要内容

AddColumns

向当前表格添加新列。

语法​

expression.AddColumns(oCell, nCount, isBefore);

expression - 表示 ApiTable 类的变量。

参数​

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

返回值​

ApiTable | null

示例​

在演示文稿中向表格添加新列。

// Useful for adding multiple columns to a table at once.

// Create a table and add two columns after the first column.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
const table = Api.CreateTable(2, 2);
const cell = table.GetCell(0, 0);
table.AddColumns(cell, 2);
const paragraph = Api.CreateParagraph();
paragraph.AddText("Two columns added. Total columns: " + table.GetRow(0).GetCellsCount());
cell.GetContent().Push(paragraph);
table.SetSize(200*36000, 100*36000);
slide.RemoveAllObjects();
slide.AddObject(table);