跳到主要内容

SetThemeColors

设置当前电子表格的主题颜色。

语法

expression.SetThemeColors(sTheme);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
sTheme必需string将设置到当前电子表格的配色方案。

返回值

boolean

示例

应用命名的颜色主题以更改电子表格的整体视觉风格。

// How do I pick and activate one of the available color themes for the whole document in a spreadsheet?

// Update the document's palette by selecting a theme from the list of built-in options in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let themes = Api.GetThemesColors();
for (let i = 0; i < themes.length; ++i) {
worksheet.GetRange("A" + (i + 1)).SetValue(themes[i]);
}
Api.SetThemeColors(themes[3]);
worksheet.GetRange("C3").SetValue("The 'Apex' theme colors were set to the current spreadsheet.");