SetFill
设置当前形状的填充属性。
语法
expression.SetFill(oFill);
expression - 表示 ApiShape 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| oFill | 必需 | ApiFill | 用于填充形状的填充类型。 |
返回值
boolean
示例
为形状设置纯色填充。
// Creates a rectangle and applies a red fill to it.
let worksheet = Api.GetActiveSheet();
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = worksheet.AddShape("rect", 60 * 36000, 40 * 36000, Api.CreateNoFill(), stroke, 3, 0, 2, 2);
worksheet.GetRange("A1").SetValue("Original shape with no fill");
let fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 0, 0));
shape.SetFill(fill);
worksheet.GetRange("A2").SetValue("Fill changed to red");