我找到了这个触发器 onSelectionChange(e)在developers.google.com 上,如果选择了单个空单元格,则应将背景设置为红色。我只是复制和粘贴没有得到那个结果。我认为我没有遗漏任何帮助,我们将不胜感激。
/**
* The event handler triggered when the selection changes in the spreadsheet.
* @param {Event} e The onSelectionChange event.
*/
function onSelectionChange(e) {
// Set background to red if a single empty cell is selected.
var range = e.range;
if(range.getNumRows() === 1
&& range.getNumColumns() === 1
&& range.getCell(1, 1).getValue() === "") {
range.setBackground("red");
}
}
最佳答案
更新:
似乎它已完全向所有用户推出。您应该能够在不修改代码的情况下使其工作。 e
,事件对象类似于onEdit
事件对象。onSelectionChange
是最近推出的功能。考虑等待几天将该功能推广到您的特定项目和电子表格。
关于google-apps-script - 使用 onSelectionChange 时我做错了什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61408971/