首页 > 解决方案 > Google App-Script save global Spreadsheet scirpt

问题描述

So I was using spreadsheets for a Game to ease things up for me and be organized about it. I am using sheets that contain information on columns A:D and a random amount of rows.

Column D is a data validation checkbox.

After some time I started removing checked lines manually because I didn't need them anymore and I thought maybe I'd see if I can automate the deletion in google and found out about AppScripts. My script works as Follows ->

I've written an Event based trigger that reacts to sheet manipulation. I then check if the checkbox was ticked and if so remove the row.

Here's my problem:

After I removed all rows of the sheet I wanted to delete the entire document. Next time I'm playing I'd import a new csv file with completely different data into the sheet and want to use the same AppScript again on that new document. The thing is I seem to be unable to create a script that is available to all SpreadSheet documents. The AppScript seems to be only existent in that one document. I found out that I can have independent AppScript projects but if I try to add a trigger to those I can only use timed triggers and not event based ones.

The questions would be:

  1. Can I somehow save an AppScript project that is independet from a specific Google Sheets Document so I can use that (and an Event based trigger) in any new document that I might create?

Thank you for reading ;)

标签: google-apps-scriptgoogle-sheets

解决方案


您可以创建一个独立的脚本,并从中为所有需要它们的电子表格创建可安装的触发器。请记住,除非您使用 Run > Test 作为附加功能,否则简单的触发器在独立脚本中不起作用。

注意:https://script.google.com上脚本的触发器页面将列出所有触发器,但不会显示针对哪个电子表格执行的触发器操作,因此您可能会发现记录电子表格名称/网址以使其更容易对触发器进行故障排除。

资源


推荐阅读