SetName
设置当前绘图的名称。 如果已存在同名的另一个绘图,该绘图的名称将重置为默认的自动生成名称。
语法
expression.SetName(name);
expression - 表示 ApiDrawing 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| name | 必需 | string | 将设置到当前绘图的名称。 |
返回值
boolean
示例
此示例展示如何为绘图对象设置名称。
const worksheet = Api.GetActiveSheet();
const fill = Api.CreateSolidFill(Api.RGB(80, 120, 160));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const drawing = worksheet.AddShape(
'ellipse',
Api.MillimetersToEmus(60), Api.MillimetersToEmus(40),
fill, stroke,
0, Api.MillimetersToEmus(20),
0, Api.MillimetersToEmus(30)
);
drawing.SetName('BlueEllipse');
const content = drawing.GetContent();
const paragraph = content.GetElement(0);
paragraph.AddText('Name: ' + drawing.GetName());
worksheet.GetRange('A1').SetValue('Drawing name was set to: ' + drawing.GetName());