Class ColorBuilder Stay organized with collections Save and categorize content based on your preferences.
Page Summary
ColorBuilder is a builder for creating color objects in Apps Script spreadsheets.
A new ColorBuilder is created using SpreadsheetApp.newColor().
The builder allows setting a color as either an RGB color using a CSS string or as a theme color using a ThemeColorType.
Once configured, the build() method creates the final Color object.
You can also convert a built color object to its RgbColor or ThemeColor representation and get its ColorType.
The builder forColor. To create a new builder, useSpreadsheet.
Methods
| Method | Return type | Brief description |
|---|---|---|
as | Rgb | Converts this color to anRgb. |
as | Theme | Converts this color to aTheme. |
build() | Color | Creates a color object from the settings supplied to the builder. |
get | Color | Get the type of this color. |
set | Color | Sets as RGB color. |
set | Color | Sets as theme color. |
Detailed documentation
asRgbColor()
Converts this color to anRgb.
Return
Rgb — The RGB color.
Throws
Error — if the color is not anRgb
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/spreadsheets.currentonlyhttps://www.googleapis.com/auth/spreadsheets
asThemeColor()
Converts this color to aTheme.
Return
Theme — The theme color.
Throws
Error — if the color is not aTheme.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/spreadsheets.currentonlyhttps://www.googleapis.com/auth/spreadsheets
build()
Creates a color object from the settings supplied to the builder.
Return
Color — A color object created from this builder.
getColorType()
setRgbColor(cssString)
Sets as RGB color.
Parameters
| Name | Type | Description |
|---|---|---|
css | String | The RGB color in CSS notation (such as '#ffffff'). |
Return
Color — This builder, for chaining.
setThemeColor(themeColorType)
Sets as theme color.
Parameters
| Name | Type | Description |
|---|---|---|
theme | Theme | The theme color type. |
Return
Color — This builder, for chaining.
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.