Is there any way to trigger functions of Google Sheet 1 from Google Sheet 2?

给你一囗甜甜゛ 提交于 2020-01-23 17:15:24

问题


Is there any way I can trigger functions of Google Sheet 1 script editor from Google sheet 2?

I read the documentation of google sheet scripts and found out about libraries but having trouble understanding how it works: 1) In properties of project by the project key, it says "Depreciated" - does that means i cannot share libraries anymore?

2) In google sheet 2, when i am trying to add library by entering project key of Google sheet 1, i keep getting following error:

The selected library must have a saved version in order to be included in another script. Open the project you wish to add as a library, save a version and try again.


回答1:


To successfully add a library of script #1 to script #2, follow these steps:

(1) Create a library of script #1 in File > Manage Versions... and Save New Version, as explained here.

(2) Copy the Script ID of script #1 in File > Project properties... (not Project key).

(3) Use library created in step 1: in script #2, go to Resources > Libraries... and add the Script ID you retrieved in step 2, as explained here.

Update:

Once you have added the library to script #2, you can access its functions by writing the word you added to field Identifier in step 3. For example, if the library identifier is set to YourLibrary and one of the functions in the library is called yourFunction, you can run that function in your second script by writing YourLibrary.yourFunction().

I hope this is of any help.



来源:https://stackoverflow.com/questions/59392780/is-there-any-way-to-trigger-functions-of-google-sheet-1-from-google-sheet-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!