使用Apps脚本检测Google电子表格中的背景颜色变化 [英] Detect Background Color Change in Google Spreadsheet with Apps Script

查看:142
本文介绍了使用Apps脚本检测Google电子表格中的背景颜色变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google App Script中创建了一个 onEdit()触发器,但只能在更改单元格的值时有效;不是当我改变背景颜色。如何解决它?

I created an onEdit() trigger in Google App Script, but it only works when I change the value of a cell; not when I change the background color. How can I fix it?

推荐答案

注意:onChange(e)有一个开放的问题来报告它不工作。请参阅 Google脚本onChange事件不再起火

NOTE: There is an open issue about onChange(e) to report that it's not working. See Google script onChange event doens't fire anymore

而不是使用onEdit(e)使用onChange(e)。当更改单元格的背景时,e.changeType的值将为FORMAT。

Instead of using onEdit(e) use onChange(e). When the background of a cell be changed, the value of e.changeType will be FORMAT.

function onChange(e) {
   // Show a popup with a message showing the type of change.
   SpreadsheetApp.getActiveSpreadsheet().toast(e.changeType);
}

参考

  • Events Objects - Google Apps Scripts Guides

这篇关于使用Apps脚本检测Google电子表格中的背景颜色变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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