跳到主要内容

CreateTable

创建具有指定行数和列数的新表格。

Breaking Change

从版本 9.4.0 开始,参数顺序已从 Api.CreateTable(cols, rows) 更改为 Api.CreateTable(rows, cols)

语法

expression.CreateTable(rows, cols);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
rows必需number行数。
cols必需number列数。

返回值

ApiTable

示例

在文档中插入跨越整个页面宽度的 3x3 表格。

// How do I add a table to a document?

// Build a new table and stretch it to fill the entire line width in a document.

let doc = Api.GetDocument();
let table = Api.CreateTable(3, 3);
doc.Push(table);
table.SetWidth("percent", 100);