跳到主要内容

CreateTable

创建表格。

Breaking Change

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

语法

expression.CreateTable(rows, cols);

expression - 表示 Api 类的变量。

参数

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

返回值

ApiTable

示例

向演示文稿添加具有多行多列的表格。

// How do I insert a table with specific dimensions in a presentation?

// Create a table with 2 rows and 4 columns and place it on a slide in a presentation.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
const table = Api.CreateTable(2, 4);
slide.RemoveAllObjects();
slide.AddObject(table);