Class Color

  • The Color object represents a color and can be converted to an RgbColor or a ThemeColor.

  • You can get the type of the color using thegetColorType() method.

  • Converting to RgbColor or ThemeColor may throw an error if the color is not of that type.

  • Using these methods requires specific spreadsheet authorization scopes.

Color

A representation for a color.

Methods

MethodReturn typeBrief description
asRgbColor()RgbColorConverts this color to anRgbColor.
asThemeColor()ThemeColorConverts this color to aThemeColor.
getColorType()ColorTypeGet the type of this color.

Detailed documentation

asRgbColor()

Converts this color to anRgbColor.

Return

RgbColor — The RGB color.

Throws

Error — if the color is not anRgbColor

Authorization

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

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

asThemeColor()

Converts this color to aThemeColor.

Return

ThemeColor — The theme color.

Throws

Error — if the color is not aThemeColor.

Authorization

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

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

getColorType()

Get the type of this color.

Return

ColorType — The color type.

Authorization

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

  • 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 theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.