跳到主要内容

Get

根据名称返回自定义属性的值。

语法

expression.Get(name);

expression - 表示 ApiCustomProperties 类的变量。

参数

名称必需/可选数据类型默认值描述
name必需string自定义属性名称。

返回值

string | number | Date | boolean | null

示例

此示例演示如何根据名称获取自定义属性的值。

const worksheet = Api.GetActiveSheet();
const customProps = Api.GetCustomProperties();

customProps.Add("ExistingProp", "#123456");

const existingProp = customProps.Get("ExistingProp");
const nonExistentProp = customProps.Get("NonExistentProp");

let fill = Api.CreateSolidFill(Api.RGB(0, 100, 200));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = worksheet.AddShape(
"rect",
100 * 36000, 50 * 36000,
fill, stroke,
0, 0, 5, 0
);

let paragraph = shape.GetDocContent().GetElement(0);
paragraph.AddText("Existing Property Value: " + existingProp);
paragraph.AddText("\nNon-Existent Property Value: " + nonExistentProp);