Google 應用程式使用者介面執行個體中的自訂選單。指令碼只能與目前開啟文件或表單的 UI 互動,且只有在指令碼與容器綁定至文件或表單時才可。詳情請參閱選單指南。
// Add a custom menu to the active spreadsheet, including a separator and a// sub-menu.functiononOpen(e){SpreadsheetApp.getUi().createMenu('My Menu').addItem('My Menu Item','myFunction').addSeparator().addSubMenu(SpreadsheetApp.getUi().createMenu('My Submenu').addItem('One Submenu Item','mySecondFunction').addItem('Another Submenu Item','myThirdFunction'),).addToUi();}
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-12-22 (世界標準時間)。"],[[["The `Menu` class allows you to create custom menus in Google Apps Script, adding items, separators, and submenus."],["Menus can be used to provide users with easy access to script functionalities within the active document or form."],["Menu items are linked to specific functions within your script using the `addItem()` method."],["`addToUi()` inserts the created menu into the user interface of the current Google App instance."],["The provided code example demonstrates creating a basic custom menu with a submenu."]]],[]]