如何使用onChange事件通过Google Sheets Apps脚本检测已删除的工作表 [英] How to use onChange event to detect deleted sheet with a Google Sheets Apps Script
问题描述
onChange事件的SpreadsheetTriggerBuilder类型为"REMOVED_ROW"
onChange event has the "REMOVED_ROW" type for a SpreadsheetTriggerBuilder
但是,在文档中没有任何地方可以看到从事件中删除了哪张工作表的方法.是否有办法通过此事件获取已删除的工作表?
However, nowhere in the documentation do I see a way to see which sheet was removed from the event. Is there a way to get the deleted sheet with this event?
推荐答案
大多数更改类型的change事件不包含可用于标识插入的已删除工作表以及其他更改的属性.为了确定受影响的工作表,我们必须保留一个电子表格工作表列表,以与当前工作表集合进行比较.为此,我们可以使用属性"服务,该服务比使用工作表更安全,因为它也可以被删除.
The change event for most of the change types doesn't include a property that could be used to identify the inserted, removed sheets among other changes. In order to identify which sheet was affected we have to keep a list of spreadsheet sheets to compare with the current sheets collection. For that we could use the Properties service that could be safer than use a sheet as it could be deleted too.
这篇关于如何使用onChange事件通过Google Sheets Apps脚本检测已删除的工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!