是否可以为多个电子表格制作一个脚本? [英] Is it possible to have one script for multiple spreadsheets?

查看:157
本文介绍了是否可以为多个电子表格制作一个脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主电子表格和一些副本。这个主电子表格使用一些脚本。



是否可以将主电子表格的所有副本链接到主电子表格中的相同脚本?



目标:


  • 主电子表格中的脚本更改由副本自动使用

  • 又名:低维护费


解决方案

amleczko是对的:应该使用Google Apps脚本中的新库功能。



但是,截至今日,您将无法完全按照您的要求进行操作(使用相同的脚本几个电子表格)。你可以做的是保存脚本的一个版本(Files> Manage Versions ...),以创建一个库。然后,将该库导入其他电子表格(资源>管理库...)。打开开发模式,所做的每一项更改都会使库使用此库立即在电子表格中发挥作用。否则,您必须为每次更改保存新版本的库,并手动更新每个电子表格中库的版本号。



问题是,您需要使用您的库在每个电子表格中编写一个脚本,并使用如下框架函数:

  function doSomething(){
myLibrary.doSomething();
}


I have one master spreadsheet and a number of copies. This master spreadsheet uses some scripting.

Is it possible to link all the copies of this master spreadsheet to the same script as in the master spreadsheet?

Objective:

  • changes in the scripting in the master spreadsheet are automatically used by the copies
  • aka: low maintenance

解决方案

amleczko is right: you should use the new library feature in Google Apps script.

However, as of today, you won't be able to do exactly what you want (using the same script for several spreadsheets). What you can do instead is save a version of your script (Files > Manage Versions...), in order to create a library. Then, import this library in the other spreadsheets (Resources > Manage Libraries...). Switch on the "development mode" so every change made do the library will immediately take affect in the spreadsheets using this library. Otherwise, you will have to save a new version of the library for every change, and manually update the version number of the library in every spreadsheets using it.

The problem is, you need to write a script in every spreadsheets using your library, with skeleton functions like this:

function doSomething(){
   myLibrary.doSomething();
} 

这篇关于是否可以为多个电子表格制作一个脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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