0

发布插件
Google Workspace Marketplace SDK

  1. 应用程序配置
    部署 ID:
    Sheets 插件项目脚本 ID:
    Sheets 插件脚本版本:
  2. 商品详情
    发布

代码.gs

// Can’t call SpreadsheetApp.getUi()  
// as a Global when the add-on is installed but not enabled.
// SpreadsheetApp is initialized when it is called in a function
var ui = function(){
  return SpreadsheetApp.getUi()}

function onOpen() {
  ui()
    .createAddonMenu()
    .addItem('Prepare sheet...', 'prepareSheet_')
    .addItem('Generate step-by-step...', 'generateStepByStep_') 
    .addToUi();
}

/**
 * A function that adds headers and some initial data to the spreadsheet.
 */
function prepareSheet_() {}

/**
 * Creates a new sheet containing step-by-step directions between the two
 * addresses on the "Settings" sheet that the user selected.
 */
function generateStepByStep_() {}

4

1 回答 1

0

您需要使用方法addSubMenu(menu)

另请参阅Google Workspace 中的自定义菜单

样本:

function onOpen() {
  var ui = SpreadsheetApp.getUi()
  ui
  .createAddonMenu()
  .addSubMenu(ui.createMenu('Prepare sheet...')
              .addSubMenu(ui.createMenu('Generate step-by-step...')
                          .addItem("Help", 'generateHelp_')))
  .addToUi();
}

在此处输入图像描述

笔记:

当您发布插件时,Google 会在插件Help菜单中添加一个附加的默认菜单 - 除了嵌套在Generate step-by-step....

于 2021-08-09T07:34:49.737 回答