跳到主要内容

ThemeColor

创建主题颜色。

语法

expression.ThemeColor(name);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
name可选SchemeColorId"tx1"主题颜色名称。如果提供的名称不受支持,将使用 'tx1' 颜色。

返回值

ApiColor

示例

使用主题强调色作为电子表格中形状的背景填充。

// How do I fill a shape with one of the document's built-in theme colors in a spreadsheet?

// Draw a rectangle filled with a coordinated theme color to maintain consistent styling in a spreadsheet.

const worksheet = Api.GetActiveSheet();
const color = Api.ThemeColor('accent6');
const fill = Api.CreateSolidFill(color);
const stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.RGB(0, 0, 0)));
worksheet.AddShape("rect", 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);