Enum ParagraphHeading
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
段落標題列舉標準段落標題。
如要呼叫列舉,請呼叫其父項類別、名稱和屬性。例如
DocumentApp.ParagraphHeading.NORMAL
。
使用 ParagraphHeading
列舉來設定 ParagraphElement
的標題樣式。
const body =
DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();
// Append a paragraph, with heading 1.
const par1 = body.appendParagraph('Title');
par1.setHeading(DocumentApp.ParagraphHeading.HEADING1);
// Append a paragraph, with heading 2.
const par2 = body.appendParagraph('SubTitle');
par2.setHeading(DocumentApp.ParagraphHeading.HEADING2);
// Append a paragraph, with normal heading.
const par3 = body.appendParagraph('Text');
par3.setHeading(DocumentApp.ParagraphHeading.NORMAL);
屬性
屬性 | 類型 | 說明 |
NORMAL | Enum | 一般文字的標題選項。 |
HEADING1 | Enum | 最高級別的標題選項。 |
HEADING2 | Enum | 第二個標題選項。 |
HEADING3 | Enum | 第三個標題選項 |
HEADING4 | Enum | 第四個標題選項。 |
HEADING5 | Enum | 第五個標題選項。 |
HEADING6 | Enum | 最底層的標題選項。 |
TITLE | Enum | 標題標題選項。 |
SUBTITLE | Enum | 字幕標題選項。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003e\u003ccode\u003eParagraphHeading\u003c/code\u003e enumeration is used to set heading styles for paragraphs in Google Docs.\u003c/p\u003e\n"],["\u003cp\u003eYou can use properties like \u003ccode\u003eNORMAL\u003c/code\u003e, \u003ccode\u003eHEADING1\u003c/code\u003e to \u003ccode\u003eHEADING6\u003c/code\u003e, \u003ccode\u003eTITLE\u003c/code\u003e, and \u003ccode\u003eSUBTITLE\u003c/code\u003e to define different heading levels.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code snippet demonstrates how to append paragraphs with different heading styles using \u003ccode\u003esetHeading()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThe table lists all available \u003ccode\u003eParagraphHeading\u003c/code\u003e properties, their types, and descriptions.\u003c/p\u003e\n"]]],[],null,["# Enum ParagraphHeading\n\nParagraphHeading\n\nAn enumeration of the standard paragraph headings.\n\nTo call an enum, you call its parent class, name, and property. For example, `\nDocumentApp.ParagraphHeading.NORMAL`.\n\nUse the `Paragraph``Heading` enumeration to configure the heading style for `Paragraph``Element`.\n\n```javascript\nconst body =\n DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();\n\n// Append a paragraph, with heading 1.\nconst par1 = body.appendParagraph('Title');\npar1.setHeading(DocumentApp.ParagraphHeading.HEADING1);\n\n// Append a paragraph, with heading 2.\nconst par2 = body.appendParagraph('SubTitle');\npar2.setHeading(DocumentApp.ParagraphHeading.HEADING2);\n\n// Append a paragraph, with normal heading.\nconst par3 = body.appendParagraph('Text');\npar3.setHeading(DocumentApp.ParagraphHeading.NORMAL);\n``` \n\n### Properties\n\n| Property | Type | Description |\n|------------|--------|-------------------------------------|\n| `NORMAL` | `Enum` | The heading option for normal text. |\n| `HEADING1` | `Enum` | The highest heading option. |\n| `HEADING2` | `Enum` | The second heading option. |\n| `HEADING3` | `Enum` | The third heading option |\n| `HEADING4` | `Enum` | The fourth heading option. |\n| `HEADING5` | `Enum` | The fifth heading option. |\n| `HEADING6` | `Enum` | The lowest heading option. |\n| `TITLE` | `Enum` | The title heading option. |\n| `SUBTITLE` | `Enum` | The subtitle heading option. |"]]