Enum Attribute
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
屬性元素屬性的列舉。
如要呼叫列舉,請呼叫其父項類別、名稱和屬性。例如
DocumentApp.Attribute.BACKGROUND_COLOR
。
使用屬性來組合自訂樣式。例如:
// Define a style with yellow background.
const highlightStyle = {};
highlightStyle[DocumentApp.Attribute.BACKGROUND_COLOR] = '#FFFF00';
highlightStyle[DocumentApp.Attribute.BOLD] = true;
// Insert "Hello", highlighted.
DocumentApp.getActiveDocument()
.getActiveTab()
.asDocumentTab()
.editAsText()
.insertText(0, 'Hello\n')
.setAttributes(0, 4, highlightStyle);
屬性
屬性 | 類型 | 說明 |
BACKGROUND_COLOR | Enum | 元素 (段落、表格等) 或文件的背景顏色。 |
BOLD | Enum | 適用於富文字的字型粗細設定。 |
BORDER_COLOR | Enum | 表格元素的邊框顏色。 |
BORDER_WIDTH | Enum | 表格元素的框線寬度,以點為單位。 |
CODE | Enum | 等式元素的程式碼內容。 |
FONT_FAMILY | Enum | 適用於富文字的字型系列設定。 |
FONT_SIZE | Enum | 富文字的字型大小設定 (以點為單位)。 |
FOREGROUND_COLOR | Enum | RTF 格式文字的前景顏色設定。 |
HEADING | Enum | 段落元素的標題類型 (例如 DocumentApp.ParagraphHeading.HEADING1 )。 |
HEIGHT | Enum | 圖片元素的高度設定。 |
HORIZONTAL_ALIGNMENT | Enum | 段落元素 (例如 DocumentApp.HorizontalAlignment.CENTER ) 的水平對齊方式。 |
INDENT_END | Enum | 段落元素的結尾縮排設定,以點為單位。 |
INDENT_FIRST_LINE | Enum | 段落元素的首行縮排設定 (以點為單位)。 |
INDENT_START | Enum | 段落元素的起始縮排設定,以點為單位。 |
ITALIC | Enum | 適用於富文字的字型樣式設定。 |
GLYPH_TYPE | Enum | 清單項目元素的圖示類型。 |
LEFT_TO_RIGHT | Enum | 文字方向設定,適用於富文字。 |
LINE_SPACING | Enum | 段落元素的線距設定係數。 |
LINK_URL | Enum | 複合式文字的連結網址。系統會自動套用預設連結樣式 (前景色彩、底線)。 |
LIST_ID | Enum | 包含清單的 ID,適用於清單項目元素。 |
MARGIN_BOTTOM | Enum | 段落元素的下邊界設定,以點為單位。 |
MARGIN_LEFT | Enum | 段落元素的左邊界設定,以點為單位。 |
MARGIN_RIGHT | Enum | 段落元素的右邊界設定,以點為單位。 |
MARGIN_TOP | Enum | 段落元素的上邊界設定,以點為單位。 |
NESTING_LEVEL | Enum | 清單項目元素的項目巢狀層級。 |
MINIMUM_HEIGHT | Enum | 表格資料列元素的最小高度設定 (以點為單位)。 |
PADDING_BOTTOM | Enum | 表格儲存格元素的底部邊框間距設定 (以點為單位)。 |
PADDING_LEFT | Enum | 表格單元格元素的左邊框間距設定 (以點為單位)。 |
PADDING_RIGHT | Enum | 表格儲存格元素的右邊框間距設定 (以點為單位)。 |
PADDING_TOP | Enum | 表格儲存格元素的頂部邊框間距設定 (以像素為單位)。 |
PAGE_HEIGHT | Enum | 文件的頁面高度設定 (以點為單位)。 |
PAGE_WIDTH | Enum | 文件的頁面寬度設定 (以點為單位)。 |
SPACING_AFTER | Enum | 段落元素的底部間距設定 (以點為單位)。 |
SPACING_BEFORE | Enum | 段落元素的頂部間距設定 (以點為單位)。 |
STRIKETHROUGH | Enum | RTF 格式文字的刪除線設定。 |
UNDERLINE | Enum | RTF 格式的底線設定。 |
VERTICAL_ALIGNMENT | Enum | 資料表儲存格元素的垂直對齊設定。 |
WIDTH | Enum | 表格儲存格和圖片元素的寬度設定。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003e\u003ccode\u003eDocumentApp.Attribute\u003c/code\u003e enumerates element attributes that can be used to define custom styles for Google Docs elements.\u003c/p\u003e\n"],["\u003cp\u003eAttributes are accessed by calling the parent class, name, and property such as \u003ccode\u003eDocumentApp.Attribute.BACKGROUND_COLOR\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can apply custom styles to elements within a Google Doc by defining a style object and setting attributes like background color, font weight, etc.\u003c/p\u003e\n"],["\u003cp\u003eA comprehensive list of available attributes and their descriptions is provided to allow detailed element styling.\u003c/p\u003e\n"]]],[],null,["# Enum Attribute\n\nAttribute\n\nAn enumeration of the element attributes.\n\nTo call an enum, you call its parent class, name, and property. For example, `\nDocumentApp.Attribute.BACKGROUND_COLOR`.\n\nUse attributes to compose custom styles. For example:\n\n```javascript\n// Define a style with yellow background.\nconst highlightStyle = {};\nhighlightStyle[DocumentApp.Attribute.BACKGROUND_COLOR] = '#FFFF00';\nhighlightStyle[DocumentApp.Attribute.BOLD] = true;\n\n// Insert \"Hello\", highlighted.\nDocumentApp.getActiveDocument()\n .getActiveTab()\n .asDocumentTab()\n .editAsText()\n .insertText(0, 'Hello\\n')\n .setAttributes(0, 4, highlightStyle);\n``` \n\n### Properties\n\n| Property | Type | Description |\n|------------------------|--------|-------------------------------------------------------------------------------------------------------------|\n| `BACKGROUND_COLOR` | `Enum` | The background color of an element (Paragraph, Table, etc) or document. |\n| `BOLD` | `Enum` | The font weight setting, for rich text. |\n| `BORDER_COLOR` | `Enum` | The border color, for table elements. |\n| `BORDER_WIDTH` | `Enum` | The border width in points, for table elements. |\n| `CODE` | `Enum` | The code contents, for equation elements. |\n| `FONT_FAMILY` | `Enum` | The font family setting, for rich text. |\n| `FONT_SIZE` | `Enum` | The font size setting in points, for rich text. |\n| `FOREGROUND_COLOR` | `Enum` | The foreground color setting, for rich text. |\n| `HEADING` | `Enum` | The heading type, for paragraph elements (for example, `Document``App.ParagraphHeading.HEADING1`). |\n| `HEIGHT` | `Enum` | The height setting, for image elements. |\n| `HORIZONTAL_ALIGNMENT` | `Enum` | The horizontal alignment, for paragraph elements (for example, `Document``App.HorizontalAlignment.CENTER`). |\n| `INDENT_END` | `Enum` | The end indentation setting in points, for paragraph elements. |\n| `INDENT_FIRST_LINE` | `Enum` | The first line indentation setting in points, for paragraph elements. |\n| `INDENT_START` | `Enum` | The start indentation setting in points, for paragraph elements. |\n| `ITALIC` | `Enum` | The font style setting, for rich text. |\n| `GLYPH_TYPE` | `Enum` | The glyph type, for list item elements. |\n| `LEFT_TO_RIGHT` | `Enum` | The text direction setting, for rich text. |\n| `LINE_SPACING` | `Enum` | The line spacing setting as a multiplier, for paragraph elements. |\n| `LINK_URL` | `Enum` | The link URL, for rich text. The default link style (foreground color, underline) is automatically applied. |\n| `LIST_ID` | `Enum` | The ID of the encompassing list, for list item elements. |\n| `MARGIN_BOTTOM` | `Enum` | The bottom margin setting in points, for paragraph elements. |\n| `MARGIN_LEFT` | `Enum` | The left margin setting in points, for paragraph elements. |\n| `MARGIN_RIGHT` | `Enum` | The right margin setting in points, for paragraph elements. |\n| `MARGIN_TOP` | `Enum` | The top margin setting in points, for paragraph elements. |\n| `NESTING_LEVEL` | `Enum` | The item nesting level, for list item elements. |\n| `MINIMUM_HEIGHT` | `Enum` | The minimum height setting in points, for table row elements. |\n| `PADDING_BOTTOM` | `Enum` | The bottom padding setting in points, for table cell elements. |\n| `PADDING_LEFT` | `Enum` | The left padding setting in points, for table cell elements. |\n| `PADDING_RIGHT` | `Enum` | The right padding setting in points, for table cell elements. |\n| `PADDING_TOP` | `Enum` | The top padding setting in points, for table cell elements. |\n| `PAGE_HEIGHT` | `Enum` | The page height setting in points, for documents. |\n| `PAGE_WIDTH` | `Enum` | The page width setting in points, for documents. |\n| `SPACING_AFTER` | `Enum` | The bottom spacing setting in points, for paragraph elements. |\n| `SPACING_BEFORE` | `Enum` | The top spacing setting in points, for paragraph elements. |\n| `STRIKETHROUGH` | `Enum` | The strike-through setting, for rich text. |\n| `UNDERLINE` | `Enum` | The underline setting, for rich text. |\n| `VERTICAL_ALIGNMENT` | `Enum` | The vertical alignment setting, for table cell elements. |\n| `WIDTH` | `Enum` | The width setting, for table cell and image elements. |"]]