Class ColorBuilder
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Szczegółowa dokumentacja
asRgbColor()
Konwertuje ten kolor na RgbColor
.
Powrót
RgbColor
– kolor RGB.
Rzuty
Error
– jeśli kolor nie jest RgbColor
Autoryzacja
Skrypty, które korzystają z tej metody, wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
asThemeColor()
Konwertuje ten kolor na ThemeColor
.
Powrót
ThemeColor
– kolor motywu.
Rzuty
Error
– jeśli kolor nie jest ThemeColor
.
Autoryzacja
Skrypty, które korzystają z tej metody, wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
build()
Tworzy obiekt koloru na podstawie ustawień przekazanych do kreatora.
Powrót
Color
– obiekt koloru utworzony za pomocą tego kreatora.
getColorType()
Określ typ tego koloru.
Powrót
ColorType
– typ koloru.
Autoryzacja
Skrypty, które korzystają z tej metody, wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setRgbColor(cssString)
Ustawia kolor RGB.
Parametry
Nazwa | Typ | Opis |
cssString | String | Kolor RGB w notacji CSS (np. #ffffff). |
Powrót
ColorBuilder
– ten kreator do łańcuchowania.
setThemeColor(themeColorType)
Ustawia kolor motywu.
Parametry
Powrót
ColorBuilder
– ten kreator do łańcuchowania.
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[null,null,["Ostatnia aktualizacja: 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eColorBuilder\u003c/code\u003e facilitates the creation and customization of color objects within Google Sheets using Apps Script.\u003c/p\u003e\n"],["\u003cp\u003eMethods such as \u003ccode\u003esetRgbColor()\u003c/code\u003e and \u003ccode\u003esetThemeColor()\u003c/code\u003e are used to define the color, while \u003ccode\u003ebuild()\u003c/code\u003e generates the final \u003ccode\u003eColor\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003easRgbColor()\u003c/code\u003e and \u003ccode\u003easThemeColor()\u003c/code\u003e methods enable the conversion of the color to specific color types.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetColorType()\u003c/code\u003e reveals the color's current type (RGB or Theme).\u003c/p\u003e\n"],["\u003cp\u003eSeveral of these methods necessitate authorization with relevant scopes for access to spreadsheet data.\u003c/p\u003e\n"]]],["ColorBuilder facilitates creating color objects using `SpreadsheetApp.newColor()`. It allows conversion to `RgbColor` or `ThemeColor`. Key actions include `build()` to create a color object, `getColorType()` to retrieve the color type, `setRgbColor(cssString)` to define an RGB color, and `setThemeColor(themeColorType)` to define a theme color. Methods may require specific authorization scopes like `spreadsheets.currentonly` or `spreadsheets`. The builder can be chained.\n"],null,["# Class ColorBuilder\n\nColorBuilder\n\nThe builder for [ColorBuilder](#). To create a new builder, use [SpreadsheetApp.newColor()](/apps-script/reference/spreadsheet/spreadsheet-app#newColor()). \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------------------|--------------------------------------------------------------|----------------------------------------------------------------------------------------|\n| [asRgbColor()](#asRgbColor()) | [RgbColor](../base/rgb-color.html) | Converts this color to an [RgbColor](../base/rgb-color.html). |\n| [asThemeColor()](#asThemeColor()) | [ThemeColor](/apps-script/reference/spreadsheet/theme-color) | Converts this color to a [ThemeColor](/apps-script/reference/spreadsheet/theme-color). |\n| [build()](#build()) | [Color](/apps-script/reference/spreadsheet/color) | Creates a color object from the settings supplied to the builder. |\n| [getColorType()](#getColorType()) | [ColorType](../base/color-type.html) | Get the type of this color. |\n| [setRgbColor(cssString)](#setRgbColor(String)) | [ColorBuilder](#) | Sets as RGB color. |\n| [setThemeColor(themeColorType)](#setThemeColor(ThemeColorType)) | [ColorBuilder](#) | Sets as theme color. |\n\nDetailed documentation\n----------------------\n\n### `as``Rgb``Color()`\n\nConverts this color to an [RgbColor](../base/rgb-color.html).\n\n#### Return\n\n\n[RgbColor](../base/rgb-color.html) --- The RGB color.\n\n#### Throws\n\n\n[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the color is not an [RgbColor](../base/rgb-color.html)\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### `as``Theme``Color()`\n\nConverts this color to a [ThemeColor](/apps-script/reference/spreadsheet/theme-color).\n\n#### Return\n\n\n[ThemeColor](/apps-script/reference/spreadsheet/theme-color) --- The theme color.\n\n#### Throws\n\n\n[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the color is not a [ThemeColor](/apps-script/reference/spreadsheet/theme-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### `build()`\n\nCreates a color object from the settings supplied to the builder.\n\n#### Return\n\n\n[Color](/apps-script/reference/spreadsheet/color) --- A color object created from this builder.\n\n*** ** * ** ***\n\n### `get``Color``Type()`\n\nGet the type of this color.\n\n#### Return\n\n\n[ColorType](../base/color-type.html) --- The color type.\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``Rgb``Color(cssString)`\n\nSets as RGB color.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------------|----------|----------------------------------------------------|\n| `css``String` | `String` | The RGB color in CSS notation (such as '#ffffff'). |\n\n#### Return\n\n\n[ColorBuilder](#) --- This builder, for chaining.\n\n*** ** * ** ***\n\n### `set``Theme``Color(themeColorType)`\n\nSets as theme 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\n#### Return\n\n\n[ColorBuilder](#) --- This builder, for chaining."]]