跳到主要内容

SetCategory

设置文档类别。

语法

expression.SetCategory(sCategory);

expression - 表示 ApiCore 类的变量。

参数

名称必需/可选数据类型默认值描述
sCategory必需string文档类别。

返回值

此方法不返回任何数据。

示例

此示例演示如何使用 ApiCore 设置演示文稿的类别。

const presentation = Api.GetPresentation();
const core = presentation.GetCore();
core.SetCategory("Examples");

const fill = Api.CreateSolidFill(Api.RGB(200, 50, 200));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("rect", 200 * 36000, 100 * 36000, fill, stroke);
shape.SetPosition(0, 0);

const docContent = shape.GetDocContent();
const paragraph = docContent.GetElement(0);
const category = core.GetCategory();
paragraph.AddText("Category: " + category);

const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();
slide.AddObject(shape);