Class SpreadsheetTheme
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
详细文档
getConcreteColor(themeColorType)
返回有效主题颜色类型的具体 Color
。如果当前主题中未设置主题颜色类型,则会抛出异常。
参数
返回
Color
- 混凝土色。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getFontFamily()
返回主题的字体系列;如果是 null
主题,则返回 null
。
返回
String
- 主题字体系列。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getThemeColors()
返回当前主题的所有可能主题颜色类型的列表。
返回
ThemeColorType[]
- 主题颜色列表。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setConcreteColor(themeColorType, color)
将此配色方案中与 ThemeColorType
关联的具体颜色设为指定颜色。
参数
返回
SpreadsheetTheme
- 主题,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setConcreteColor(themeColorType, red, green, blue)
将与此配色方案中的 ThemeColorType
关联的具体颜色设为 RGB 格式的给定颜色。
参数
名称 | 类型 | 说明 |
themeColorType | ThemeColorType | 主题颜色类型。 |
red | Integer | 红色通道的值。 |
green | Integer | 绿色通道的值。 |
blue | Integer | 蓝色通道的值。 |
返回
SpreadsheetTheme
- 主题,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setFontFamily(fontFamily)
设置主题的字体系列。
参数
名称 | 类型 | 说明 |
fontFamily | String | 新的主题字体系列。 |
返回
SpreadsheetTheme
- 此主题,用于链式调用。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe \u003ccode\u003eSpreadsheetTheme\u003c/code\u003e object allows you to access and modify existing themes within a spreadsheet.\u003c/p\u003e\n"],["\u003cp\u003eYou can get and set theme colors using methods like \u003ccode\u003egetConcreteColor\u003c/code\u003e, \u003ccode\u003esetConcreteColor\u003c/code\u003e, and \u003ccode\u003egetThemeColors\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe font family of a theme can be retrieved and modified with \u003ccode\u003egetFontFamily\u003c/code\u003e and \u003ccode\u003esetFontFamily\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAll these methods require authorization with specific scopes, such as \u003ccode\u003ehttps://www.googleapis.com/auth/spreadsheets\u003c/code\u003e.\u003c/p\u003e\n"]]],["Spreadsheet themes can be accessed and modified using `Spreadsheet.setSpreadsheetTheme(theme)`. Key actions include retrieving the concrete color for a theme color type with `getConcreteColor(themeColorType)`, and obtaining the theme's font family using `getFontFamily()`. Users can obtain a list of theme color types with `getThemeColors()`. Themes can be altered by setting the color with `setConcreteColor()`, or setting the font family using `setFontFamily()`. Color settings can be in [Color] or RGB.\n"],null,["# Class SpreadsheetTheme\n\nSpreadsheetTheme\n\nAccess and modify existing themes. To set a theme on a spreadsheet, use [Spreadsheet.setSpreadsheetTheme(theme)](/apps-script/reference/spreadsheet/spreadsheet#setSpreadsheetTheme(SpreadsheetTheme)). \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [getConcreteColor(themeColorType)](#getConcreteColor(ThemeColorType)) | [Color](/apps-script/reference/spreadsheet/color) | Returns the concrete [Color](/apps-script/reference/spreadsheet/color) for a valid theme color type. |\n| [getFontFamily()](#getFontFamily()) | `String` | Returns the font family of the theme, or `null` if it's a `null` theme. |\n| [getThemeColors()](#getThemeColors()) | [ThemeColorType[]](/apps-script/reference/spreadsheet/theme-color-type) | Returns a list of all possible theme color types for the current theme. |\n| [setConcreteColor(themeColorType, color)](#setConcreteColor(ThemeColorType,Color)) | [SpreadsheetTheme](#) | Sets the concrete color associated with the [ThemeColorType](/apps-script/reference/spreadsheet/theme-color-type) in this color scheme to the given color. |\n| [setConcreteColor(themeColorType, red, green, blue)](#setConcreteColor(ThemeColorType,Integer,Integer,Integer)) | [SpreadsheetTheme](#) | Sets the concrete color associated with the [ThemeColorType](/apps-script/reference/spreadsheet/theme-color-type) in this color scheme to the given color in RGB format. |\n| [setFontFamily(fontFamily)](#setFontFamily(String)) | [SpreadsheetTheme](#) | Sets the font family for the theme. |\n\nDetailed documentation\n----------------------\n\n### `get``Concrete``Color(themeColorType)`\n\nReturns the concrete [Color](/apps-script/reference/spreadsheet/color) for a valid theme color type. Throws exception if the theme\ncolor type is not set in the current theme.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------------|-----------------------------------------------------------------------|-------------------|\n| `theme``Color``Type` | [ThemeColorType](/apps-script/reference/spreadsheet/theme-color-type) | Theme color type. |\n\n#### Return\n\n\n[Color](/apps-script/reference/spreadsheet/color) --- Concrete color.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Font``Family()`\n\nReturns the font family of the theme, or `null` if it's a `null` theme.\n\n#### Return\n\n\n`String` --- The theme font family.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Theme``Colors()`\n\nReturns a list of all possible theme color types for the current theme.\n\n#### Return\n\n\n[ThemeColorType[]](/apps-script/reference/spreadsheet/theme-color-type) --- A list of theme colors.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `set``Concrete``Color(themeColorType, color)`\n\nSets the concrete color associated with the [ThemeColorType](/apps-script/reference/spreadsheet/theme-color-type) in this color scheme to the\ngiven color.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------------|-----------------------------------------------------------------------|-----------------------|\n| `theme``Color``Type` | [ThemeColorType](/apps-script/reference/spreadsheet/theme-color-type) | The theme color type. |\n| `color` | [Color](/apps-script/reference/spreadsheet/color) | The color. |\n\n#### Return\n\n\n[SpreadsheetTheme](#) --- The theme, for chaining.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `set``Concrete``Color(themeColorType, red, green, blue)`\n\nSets the concrete color associated with the [ThemeColorType](/apps-script/reference/spreadsheet/theme-color-type) in this color scheme to the\ngiven color in RGB format.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------------|-----------------------------------------------------------------------|-----------------------------|\n| `theme``Color``Type` | [ThemeColorType](/apps-script/reference/spreadsheet/theme-color-type) | The theme color type. |\n| `red` | `Integer` | The value of red channel. |\n| `green` | `Integer` | The value of green channel. |\n| `blue` | `Integer` | The value of blue channel. |\n\n#### Return\n\n\n[SpreadsheetTheme](#) --- The theme, for chaining.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `set``Font``Family(fontFamily)`\n\nSets the font family for the theme.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------|----------|----------------------------|\n| `font``Family` | `String` | The new theme font family. |\n\n#### Return\n\n\n[SpreadsheetTheme](#) --- This theme, for chaining.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`"]]