菜单项未显示在Google表格插件中 [英] Menu items do not appear in Google Sheets add-on

查看:93
本文介绍了菜单项未显示在Google表格插件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作这个插件插件,该插件可以帮助我和其他人将工作表导出为JSON.在我的测试中,菜单显示出来,所有功能正常工作(如屏幕截图所示).当我发送要在Google Web Store上发布的信息时,文档加载项顾问"看不到评论中的菜单.因此,正如文档插件顾问"建议的那样,我将其发布为未列出",以查看它是否对我有利.而且它不起作用.这是我正在使用的代码和链接.谁能告诉我我在做什么错,并帮助我解决问题.

I am trying to make this add-on plugin that can help me and other to export sheet in to JSON. In my testing it's the menu shows up and all the functionality works (as you see in screenshots). When I sent for publish on Google Web Store the "Docs Add-ons Advisor" don't see the menu in the review. So as "Docs Add-ons Advisor" suggested I published it "Unlisted" to see if it work on my side. And it doesn't work. Here is the code I am using and links. Can anyone tell me what I am doing wrong and help me fix it.

插件(未列出): https://chrome.google.com/webstore/detail/export-to-json/fcnpcmlbpljjcecefcgllklhbgppinbdd?hl=zh-CN&gl=US&authuser=0

参考:

代码:

function onInstall(e) {
  onOpen(e);
}

function onOpen(e) {
  var menu = SpreadsheetApp.getUi().createAddonMenu(); // Or DocumentApp or FormApp.

  if (e && e.authMode == ScriptApp.AuthMode.NONE) {
  // Add a normal menu item (works in all authorization modes).
    menu.addItem('Export to JSON', 'exportInit');
  } else {
    // Add a menu item based on properties (doesn't work in AuthMode.NONE).
    var properties = PropertiesService.getDocumentProperties();
    var workflowStarted = properties.getProperty('workflowStarted');
    if (workflowStarted) {
      menu.addItem('Start to JSON', 'startJson');
    } else {
      menu.addItem('Export to JSON', 'exportInit');
    }
  }
  menu.addToUi();
}

function startJson(){
  ...code...
}
function exportInit() {
  ..code..
}

推荐答案

我遇到了类似的问题.但是我的问题是我声明了全局变量,这基本上阻止了onOpen(e)运行.

I had similar problem. But my problem was that I declared global variables which basically prevented onOpen(e) from running.

我确实看到您没有在示例代码中声明全局变量.

I do see that you're not declaring global variables in your example code, though.

这篇关于菜单项未显示在Google表格插件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆