这是我编写的函数,它会在编辑指定的单元格/行/列时发送电子邮件通知某人,并且我将其设置为触发 onEdit。它按原样工作。
/* This function send an email when a specified range is edited
* The spreadsheets triggers must be set to onEdit for the function
*/
function sendNotification() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
//Get Active cell
var mycell = ss.getActiveSelection();
var cellcol = mycell.getColumn();
var cellrow = mycell.getRow();
//Define Notification Details
var recipients = "me@email.com";
var subject = "Update to "+ss.getName();
var body = ss.getName() + "has been updated. Visit " + ss.getUrl() + " to view the changes.";
//Check to see if column is A or B to trigger
if (cellcol == 1, 2)
{
//check for row to trigger
if (cellrow == 1)
{
//Send the Email
MailApp.sendEmail(recipients, subject, body);
}
//End sendNotification
}
}
我的问题是,只有当电子表格的某个工作表(页面)上的列或行被编辑时,我才需要这个工作,而不是电子表格中任何工作表中的 X 列。
有任何想法吗?我希望这是我错过的简单事情,但我一直无法找到解决方案。