Class SpreadsheetTheme

  • SpreadsheetTheme allows access and modification of existing spreadsheet themes.

  • You can set a theme on a spreadsheet using Spreadsheet.setSpreadsheetTheme(theme).

  • Methods are available to get and set concrete colors for theme color types and to get and set the font family of a theme.

  • Methods like getConcreteColor and getFontFamily return theme properties, while methods like setConcreteColor and setFontFamily modify them and return the theme object for chaining.

  • Using these methods requires specific authorization scopes related to accessing and modifying spreadsheets.

SpreadsheetTheme

Access and modify existing themes. To set a theme on a spreadsheet, use Spreadsheet.setSpreadsheetTheme(theme) .

Methods

MethodReturn typeBrief description
getConcreteColor(themeColorType) Color Returns the concrete Color for a valid theme color type.
getFontFamily() String|nullReturns the font family of the theme, or null if it's a null theme.
getThemeColors() ThemeColorType[] Returns a list of all possible theme color types for the current theme.
setConcreteColor(themeColorType, color) SpreadsheetTheme Sets the concrete color associated with the ThemeColorType in this color scheme to the given color.
setConcreteColor(themeColorType, red, green, blue) SpreadsheetTheme Sets the concrete color associated with the ThemeColorType in this color scheme to the given color in RGB format.
setFontFamily(fontFamily) SpreadsheetTheme Sets the font family for the theme.

Detailed documentation

getConcreteColor(themeColorType)

Returns the concrete Color for a valid theme color type. Throws exception if the theme color type is not set in the current theme.

Parameters

NameTypeDescription
themeColorTypeThemeColorType Theme color type.

Return

Color — Concrete color.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getFontFamily()

Returns the font family of the theme, or null if it's a null theme.

Return

String|null — The theme font family.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getThemeColors()

Returns a list of all possible theme color types for the current theme.

Return

ThemeColorType[] — A list of theme colors.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setConcreteColor(themeColorType, color)

Sets the concrete color associated with the ThemeColorType in this color scheme to the given color.

Parameters

NameTypeDescription
themeColorTypeThemeColorType The theme color type.
colorColor The color.

Return

SpreadsheetTheme — The theme, for chaining.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setConcreteColor(themeColorType, red, green, blue)

Sets the concrete color associated with the ThemeColorType in this color scheme to the given color in RGB format.

Parameters

NameTypeDescription
themeColorTypeThemeColorType The theme color type.
redIntegerThe value of red channel.
greenIntegerThe value of green channel.
blueIntegerThe value of blue channel.

Return

SpreadsheetTheme — The theme, for chaining.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setFontFamily(fontFamily)

Sets the font family for the theme.

Parameters

NameTypeDescription
fontFamilyStringThe new theme font family.

Return

SpreadsheetTheme — This theme, for chaining.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年12月11日 UTC.