如何通过api编辑spreasheet时让onEdit事件在Google Apps脚本中被捕获? [英] How to get the onEdit event to to be caught in a Google Apps Script when editing a spreasheet via api?

查看:74
本文介绍了如何通过api编辑spreasheet时让onEdit事件在Google Apps脚本中被捕获?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序脚本,可以在手动编辑某个Google Spreadsheet单元格时捕获onEdit事件,并根据更改应用各种格式更改。

然而,当我使用Google Drive API编辑同一个单元格时,脚本看起来并没有运行。



有没有办法通过api触发事件被应用程序脚本抓住了?或者其他一些解决方案呢?

解决方案

发布为网络应用程序:

可以使用URL从Google apps脚本编辑器Menu-> publish-> Publish as web app触发Google apps脚本代码。
然后,您可以将单元格的ID作为参数传递给Web应用程序。并让网络应用程序调用onEdit。



我怀疑google-spreadsheet-api没有办法做到这一点,因为即使是基本的东西,比如在表格的中间插入一行,不存在。

I have an apps script that captures the onEdit event when I edit a certain Google Spreadsheet cell manually, and applies various formatting changes based on the change.

However, when I edit the same cell using the Google Drive API, the script doesn't seem to run.

Is there some way to trigger an event via the api which can be caught by the apps script? Or some other solution for this?

解决方案

Publish as a web app:

it is possible to trigger Google apps script code using a URL, i.e. from the Google apps script editor Menu->publish->Publish as web app. You can then pass the id of the cell as a parameter to the "web app". and have the web app call the onEdit.

I suspect the "google-spreadsheet-api" has no way to do this, as even basic things such as "insert a row in the middle of a sheet", don't exist.

这篇关于如何通过api编辑spreasheet时让onEdit事件在Google Apps脚本中被捕获?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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