【问题标题】:How to get the onEdit event to to be caught in a Google Apps Script when editing a spreasheet via api? [duplicate]通过 api 编辑电子表格时,如何在 Google Apps 脚本中捕获 onEdit 事件? [复制]
【发布时间】:2013-02-08 15:22:17
【问题描述】:
我有一个应用程序脚本,当我手动编辑某个 Google 电子表格单元格时,它会捕获 onEdit 事件,并根据更改应用各种格式更改。
但是,当我使用 Google Drive API 编辑同一个单元格时,脚本似乎没有运行。
是否有某种方法可以通过应用程序脚本捕获的 api 触发事件?或者其他解决方案?
【问题讨论】:
标签:
google-apps-script
google-sheets
google-drive-api
google-spreadsheet-api
【解决方案1】:
作为网络应用发布:
可以使用 URL 触发 Google Apps 脚本代码,即从 Google Apps 脚本编辑器 Menu->publish->Publish as web app。
然后,您可以将单元格的 id 作为参数传递给“网络应用程序”。并让网络应用程序调用 onEdit。
我怀疑“google-spreadsheet-api”无法做到这一点,因为即使是“在工作表中间插入一行”这样的基本操作也不存在。