带有附加组件的自定义功能? [英] Custom Functions with add-ons?

本文介绍了带有附加组件的自定义功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试根据我现有的一些 Google 应用脚本创建一个 Google 电子表格插件,这个应用脚本的一个重要部分是自定义函数.

I've been trying to create a Google Spreadsheet plugin from some existing Google App Scripts that I have, and one important part of this app script is Custom Functions.

虽然附加组件的文档并未表明支持此功能,但自定义函数的文档确实表明您可以.

Though the documentation for the add-ons doesn't indicate that this is supported, the documentation for Custom Functions does indicate that you can.

https://developers.google.com/apps-script/guides/工作表/函数

通过测试,我从未能够通过附加组件公开自定义函数.有谁知道让它发挥作用的秘诀吗?

Through testing, I have not once been able to get Custom Functions exposed through a add-on. Does anyone know the secret sauce to get this to work?

推荐答案

答案

根据 Eric Koleda 在 [Code.gs - date_add_and_subtract]( https://github.com/google/google-apps-script-samples/blob/master/date_add_and_subtract/Code.gs) 要在加载项中提供自定义功能,需要至少包含一个加载项菜单,但目前在测试模式下不起作用.

Answer

According to Eric Koleda in [Code.gs - date_add_and_subtract]( https://github.com/google/google-apps-script-samples/blob/master/date_add_and_subtract/Code.gs) to make available the custom fuctions in an add-on it's required to include at least one add-on menu, but this is not working at this time on testing mode.

注意:最初引用的页面已删除,但日期添加和减去附加示例代码可在 https://github.com/googlesamples/apps-script/tree/master/sheets/dateAddAndSubtract.

NOTE: The originally referred page was removed but the Date add and substract add-on sample code is available at https://github.com/googlesamples/apps-script/tree/master/sheets/dateAddAndSubtract.

解决方案"测试自定义函数附加组件就是私下发布附加组件,这样您就可以避免 Google 对未经测试的附加组件进行审查.相关问答:私下发布插件

The "solution" to test a custom function add-on is to publish the add-on privately so you could avoid the Google review of an untested add-on. Related Q&A: Publish an add-on privately

  1. 您必须创建一个 Google Cloud 项目,设置 OAuth 同意屏幕,添加 Google Workspaces Marketplace SDK,完成配置页面、列表页面并发布插件
  2. 为内部使用设置 OAuth 同意屏幕需要 Google Workspace 帐户
  3. 将 OAuth 同意屏幕设置为仅限于测试帐户的外部使用不允许将插件发布到 GW 市场.

<小时>

一种情况是使用不同的 Google Cloud 项目进行测试和生产,但使用相同的 Google Apps 脚本项目.另一种情况是有两个不同的 Google Apps 脚本项目,每个项目都有自己的 Google Apps 项目,并以某种方式将代码从一个复制到另一个,即使用 Google Apps Script GitHub 助手 Chrome 扩展、CLASP 或 Google Apps Script API.


One scenario is to use different Google Cloud Projects for testing and production but use the same Google Apps Script project. Another scenario is to have two different Google Apps Script projects each one with their own Google Apps Project and someway copy the code from one to the other i.e. using Google Apps Script GitHub Assistant Chrome Extension, CLASP or the Google Apps Script API.

有几个相关的 GAS 问题,请给它们加星号:

There are a couple of related GAS issues, please star them:

这篇关于带有附加组件的自定义功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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