Class ColorBuilder
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เอกสารประกอบโดยละเอียด
asRgbColor()
แปลงสีนี้เป็น RgbColor
รีเทิร์น
RgbColor
— สี RGB
โยน
Error
— หากสีไม่ใช่ RgbColor
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
asThemeColor()
แปลงสีนี้เป็น ThemeColor
รีเทิร์น
ThemeColor
— สีธีม
โยน
Error
— หากสีไม่ใช่ ThemeColor
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
build()
สร้างออบเจ็กต์สีจากการตั้งค่าที่ระบุไว้ในโปรแกรมสร้าง
รีเทิร์น
Color
— ออบเจ็กต์สีที่สร้างจากเครื่องมือสร้างนี้
getColorType()
รับประเภทของสีนี้
รีเทิร์น
ColorType
— ประเภทสี
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setRgbColor(cssString)
ตั้งค่าเป็นสี RGB
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
cssString | String | สี RGB ในเครื่องหมายนิพจน์ CSS (เช่น "#ffffff") |
รีเทิร์น
ColorBuilder
— ตัวสร้างนี้สําหรับการต่อเชื่อม
setThemeColor(themeColorType)
ตั้งเป็นสีธีม
พารามิเตอร์
รีเทิร์น
ColorBuilder
— ตัวสร้างนี้สําหรับการต่อเชื่อม
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 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."]]