Google 应用界面实例中的自定义菜单。脚本只能与
与打开文档或表单的当前实例的界面相关联,并且仅在脚本与文档或表单绑定的情况下使用。有关
相关信息,请参阅菜单指南。
// Add a custom menu to the active spreadsheet, including a separator and a sub-menu.
function onOpen(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"]],["最后更新时间 (UTC):2024-09-12。"],[[["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."]]],[]]