為 Google 文件使用外掛程式增添功能
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Google 文件是雲端文件解決方案,提供即時協作功能和強大的工具,可撰寫、編輯及共用文件。
您可以透過外掛程式擴充 Google 文件的功能,打造自訂工作流程、建立與第三方系統的連線,以及將文件與其他 Google Workspace 應用程式 (例如 Google 簡報) 整合。
您可以在 Google Workspace Marketplace 中查看其他人建立的 Google 文件外掛程式。
建議做法
以下列舉幾項 Google 文件擴充功能的用途:
- 您可以使用內建的 Apps Script 文件服務,在 Google 文件中讀取、編輯、顯示及設定文字格式。這項服務也支援建立及修改 Google 文件中的表格、圖片、繪圖和方程式。
- 您可以使用標準 HTML 和 CSS 建立自訂選單,並定義多個自訂對話方塊和側欄介面。
- 您可以透過外掛程式觸發條件,在發生特定觸發事件時執行指定函式。
文件外掛程式是使用 Apps Script 建構而成。如要進一步瞭解如何使用 Apps Script 存取及管理 Google 文件,請參閱「擴充 Google 文件」。
文件結構
在 Google 文件中建立的文件具有樹狀結構的內部結構 (類似於 HTML 或 JSON),可定義文字、圖片、表格和其他元素顯示的位置和方式。Apps Script Document 服務定義了多個類別 (例如 Paragraph
或 Table
),可協助管理不同元素類型。
如要瞭解這些元素類別和管理排列方式的規則,請參閱「文件結構」。
觸發條件
Apps Script 觸發條件可讓指令碼專案在符合特定條件時執行指定函式,例如開啟文件或安裝外掛程式時。
如要進一步瞭解哪些觸發條件可用於文件外掛程式,以及使用時有哪些限制,請參閱外掛程式觸發條件。
開始使用
準備好查看一些程式碼了嗎?請參閱我們的外掛程式範例,包括文件外掛程式快速入門導覽課程,其中包含 Google 翻譯。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-31 (世界標準時間)。
[null,null,["上次更新時間:2025-07-31 (世界標準時間)。"],[[["\u003cp\u003eGoogle Docs is a cloud-based document solution enabling real-time collaboration and offering robust tools for composing, editing, and sharing documents.\u003c/p\u003e\n"],["\u003cp\u003eDocs add-ons, built using Apps Script, extend functionality by enabling workflow customization, integration with third-party systems, and connectivity with other Google Workspace applications.\u003c/p\u003e\n"],["\u003cp\u003eAdd-ons can manipulate document content, create custom interfaces, and automate tasks through triggers based on specific events.\u003c/p\u003e\n"],["\u003cp\u003eGoogle provides comprehensive documentation and resources, including code samples, to guide developers in building Docs add-ons.\u003c/p\u003e\n"]]],["Google Docs is a cloud-based document solution that can be extended with add-ons via Apps Script. These add-ons can read, edit, visualize, and format text, create custom menus and dialogs, and integrate with other Google Workspace applications. Add-ons utilize Apps Script triggers to run functions when specific events occur. The documents' tree-like structure is managed through the Apps Script Document service. Resources are available, including add-on samples and a quickstart guide, to help begin developing.\n"],null,["# Extending Google Docs with add-ons\n\n[Google Docs](https://workspace.google.com/products/docs/) is a cloud-based document\nsolution with real-time collaboration and powerful tools to compose, edit,\nand share documents.\n\nYou can extend Docs with add-ons that build customized workflow improvements,\nestablish connectivity to third-party systems, and integrate your documents\nwith other Google Workspace applications (like\nGoogle Slides).\n\nYou can see the Docs add-on others have built on the\n[Google Workspace Marketplace](https://workspace.google.com/marketplace/category/works-with-doc).\n\nWhat you can do\n---------------\n\nHere are a few things you can do with an add-on that extends Google Docs:\n\n- You can read, edit, visualize, and format text in Google Docs using the built-in Apps Script [Document service](/apps-script/reference/document). The service also lets you create and modify tables, images, drawings, and equations appearing in Google Docs.\n- You can create [custom menus](/workspace/add-ons/concepts/menus) and define multiple [custom dialogs and sidebars](/workspace/add-ons/concepts/dialogs) interfaces using standard HTML and CSS.\n- You can use add-on [triggers](#triggers) to run specified functions when certain triggering events occur.\n\nDocs add-ons are built using Apps Script. To learn more about how to access\nand manage Google Docs with Apps Script, see\n[Extending Google Docs](/apps-script/guides/docs).\n\nDocument structure\n------------------\n\nThe documents created in Google Docs have internal, tree-like structures\n(similar to HTML or JSON) that define where and how text, images, tables, and\nother elements appear. The Apps Script\n[Document service](/apps-script/reference/document) defines several\nclasses (such as [`Paragraph`](/apps-script/reference/document/paragraph)\nor [`Table`](/apps-script/reference/document/table)) to help manage the\ndifferent element types.\n\nSee [Structure of a document](/apps-script/guides/docs#structure_of_a_document)\nto learn about these element classes and the rules that govern their\narrangement.\n\nTriggers\n--------\n\nApps Script **triggers** let a script project execute a specified function\nwhen certain conditions are met, such as when a document is opened or when an\nadd-on is installed.\n\nSee [add-on triggers](/workspace/add-ons/concepts/editor-triggers) for more information\non what triggers can be used with Docs add-ons and what restrictions apply to\ntheir use.\n\nGetting started\n---------------\n\nWhen you're ready to take a look at some code, check out our\n[add-on samples](/workspace/add-ons/samples), including the\n[Docs add-on Quickstart](/workspace/add-ons/editors/docs/quickstart/translate)\nfeaturing Google Translate."]]