cou*_*011 0 google-apps-script
如何将onChange方法附加到Google电子表格中的单元格.我想在单元格中的值变得大于1000时立即向某人发送电子邮件?
在此示例中,如果单元格A1的值大于1000并且您自己未更改其值,则会发送邮件.
您当然应该根据需要自定义电子邮件地址和单元名称.
function sheetTracker(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var cell = ss.getActiveCell().getA1Notation();
if(Session.getActiveUser()!='yourmail@gmail.com' &&
Number(ss.getActiveCell().getValue())>1000 && cell=='A1'){
MailApp.sendEmail('yourmail@gmail.com', 'Modification in the spreadsheet',
'Cell ' + cell + ' has been modified by '+ Session.getActiveUser() +
' - new value = ' + ss.getActiveCell().getValue().toString());
}
}
Run Code Online (Sandbox Code Playgroud)
您应该添加一个可安装的触发器on edit
(转到资源>当前工作表触发器>添加新触发器)并授权该脚本.