如何从另一个项目运行google app脚本功能 [英] how to run google app script function from another project

查看:79
本文介绍了如何从另一个项目运行google app脚本功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作表很少具有绑定到电子表格的功能.每个电子表格都有其自己的功能,并使用SpreadsheetApp.getUi运行html服务.我想在主电子表格项目的所有工作表中启动函数调用吗?是否有可能?诸如获取电子表格项目的句柄并在该项目中运行脚本之类的东西?

I have few sheets that have functions bound to the spreadsheet. Each spreadsheet has its own functions and uses SpreadsheetApp.getUi to run html service. I would like to initiate function calls in all the sheets from a master spreadsheet project? is it possible? Something like getting a handle to the spreadsheet project and run a script in that project?

推荐答案

您有两个选择:

  1. 将脚本发布为库,并在彼此的脚本项目中相互订阅.
  2. 将脚本作为具有特定功能的Web应用发布为单独的伪Webhooks.有点像分布式API.

每种都有优点和缺点.两者都与可维护性无关.

There are pros and cons of each. Neither is about maintainability really.

库选项将提供代码完成功能,而Web应用程序选项将允许(如果您愿意)使您异步运行代码.

The library option will afford code completion whereas the web app option will enable (if you wish) for you to run code asynchronously.

两者都有不同的速度惩罚.如文档中所述,启用库的脚本速度较慢.由于urlfetch延迟,Web应用程序将变慢.

Both have different speed penalties. Library enabled scripts are slower as described in the documentation. Web apps will be slower because of urlfetch latency.

库函数将使用宿主脚本中允许的运行时,而Web应用程序将扩展运行时和一些配额.

Library functions will use the runtime allowed for them in the host script, whereas web apps will extend runtime and some quotas.

文档:

  1. 将脚本发布为库
  2. 将应用程序脚本作为端点运行
  1. Publish your scripts as a library
  2. Running apps script as an endpoint

这篇关于如何从另一个项目运行google app脚本功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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