简体   繁体   English

Google Apps脚本库和脚本分发

[英]Google Apps Script Library and Script Distribution

i was wondering if there is a possibility to distribute my Custom Script to all the sheets in my workspace. 我想知道是否可以将自定义脚本分发到工作区中的所有工作表。 I came upon different ways with libraries or Add-ons, but they all lack some points i want to accomplish. 我使用库或加载项遇到了不同的方式,但是它们都缺少我想完成的几点。

  1. I want it to be private only for my Google Account 我希望它仅对我的Google帐户不公开
  2. I need it to run the onOpen(e) Trigger for every File on my Sheets Account (So i can add a custom menu to all my Files) 我需要它为Sheets帐户中的每个文件运行onOpen(e)触发器(以便我可以向所有文件添加自定义菜单)
  3. I also need to set a time Trigger for each File so my main() Function runs every night (right now i always create a new trigger when i rerun my main Function) 我还需要为每个文件设置一个时间触发器,以便我的main()函数每天晚上运行(现在,当我重新运行主函数时,我总是会创建一个新的触发器)

So far i can use the Library Option and create a new Script for all my Files and call my Main Function out of that Library. 到目前为止,我可以使用Library Option并为我的所有文件创建一个新脚本,然后从该Library中调用我的Main Function。 This Workaround does not include an onOpen Trigger event. 此解决方法不包括onOpen触发事件。 When i use the Ability of run->test as addon and manually add all new Files (which come up every new month) i also lack the possibility of trigger functions. 当我使用“ 运行->测试能力” 作为插件并手动添加所有新文件(每隔一个月更新一次)时,我也没有触发功能的可能性。

If you have Solution Ideas I'd be very happy. 如果您有解决方案的想法,我将非常高兴。

BR NJ 新泽西州

  • An Add-on can be published privately. 加载项可以私下发布。 Private Add-ons 私人附加组件
  • A Library is private by default - The only way that someone outside of your account can use your script as a library, is to set the file sharing to allow them to use it. 默认情况下,库是私有的-帐户之外的其他人可以将您的脚本用作库,这是设置文件共享以允许他们使用它的唯一方法。 Gaining access to a library 访问图书馆
  • A Library can not run a simple trigger, but an Add-on can. 库不能运行简单的触发器,但是附件可以运行。 The reserved function name onOpen() can't be triggered by a library. 保留的函数名称onOpen()不能由库触发。 See Table - Resource Scoping 参见表-资源范围
  • An Add-on can run the onOpen() function 加载项可以运行onOpen()函数
  • An Add-on can create an add-on menu. 加载项可以创建加载项菜单。
  • An Add-on can create one time-based trigger for each document it is installed in. Quote: "Each add-on can only have one trigger of each type, per user, per document" Add-on Restrictions 加载项可以为安装的每个文档创建一个基于时间的触发器。Quote:“每个加载项只能为每个用户,每个文档具有一个类型的触发器。” 加载项限制

If you want to do something like overwrite an Apps Script file, that can be done with the Apps Script API. 如果您想要执行诸如覆盖Apps脚本文件的操作,则可以使用Apps Script API来完成。 Even script projects that are bound to a document (Sheets, Forms, Docs) can be overwritten with the Apps Script API. 甚至绑定到文档(表格,表单,文档)的脚本项目也可以使用Apps Script API覆盖。

StackOverflow answer - Update an Apps Script file using Apps Script StackOverflow答案-使用Apps脚本更新Apps脚本文件

You can also update the manifest file of an Apps Script file using the Apps Script API, and therefore, programmatically add a library, and the library version to an existing Apps Script File. 您还可以使用Apps Script API更新Apps脚本文件的清单文件,从而以编程方式将库和库版本添加到现有的Apps Script文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM