测试 Google Sheet 插件 [英] Test a Google Sheet add-on

查看:42
本文介绍了测试 Google Sheet 插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在脚本编辑器中使用 Code.gsIndex.html 创建了一个插件.我选择 Publish ==>测试为插件...,然后在对话框中选择另一个谷歌表.点击 Test 打开那个谷歌表,但我没有看到任何应该由 index.html, =myFunction() 制作的任务面板在单元格中也不起作用.

I have created an add-on in Script Editor with Code.gs and Index.html. I choose Publish ==> Test as add-on... and then selected another google sheet in the dialog box. Clicking on Test opens that google sheet, but I don't see any taskpane that should be made by index.html, =myFunction() does not work either in cells.

有谁知道如何测试这个附加组件?

Does anyone know how to test this add-on?

编辑 1: Code.gs:

function myFunction() {
  return 100
}

Index.html:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    super add-on
  </body>
</html>

推荐答案

您绝对可以在其他工作表中测试侧边栏插件.您需要使用以下脚本.另外,请确保您选择 INSTALLATION CONFIG 作为 Installed &已启用.

You can definitely test the sidebar add-on, in other sheet. You need to use the below script. Also, make sure you select INSTALLATION CONFIG as Installed & Enabled.

function onOpen() {
   var html = HtmlService.createHtmlOutputFromFile('index') //your html page name
      .setTitle('My custom sidebar')
      .setWidth(300);
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .showSidebar(html);
}

目前,自定义函数在测试插件模式下不起作用.已经为此报告了一个问题,谷歌已接受它.检查这个.

Currently, custom functions are not working in test add-on mode. There is already an issue reported for this and Google as accepted it. Check this.

这篇关于测试 Google Sheet 插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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