如何在Google Spreadsheet中记录删除事件 [英] How to record delete events in Google Spreadsheet
问题描述
我需要使用Google Apps脚本(删除单元格或整个行)在Google电子表格中记录删除事件,并获取单元格编号和用户名.
I need to record the delete events in my Google Spreadsheet using Google Apps Script (delete a cell or entire row) and get the cell number and user name.
功能onEdit(e)
在单元格被编辑时触发,而不是在删除时触发.
Function onEdit(e)
triggers when cells are edited and not when deleted.
function onEdit(e)
{
var range = e.range;
Logger.log(range.getRow());
Logger.log(Session.getActiveUser().getEmail());
if (range.getRow() === 3.0)
{
var recipient = "user@example.com";
var subject = 'Roster Notification';
MailApp.sendEmail(recipient, subject, "Hello, your roster has been updated. Please check. Thanks.");
}
}
推荐答案
更新:
下面链接的问题#2已修复,可以使用getActiveRange()
检索正确的行.
Update:
Issue#2 linked below is fixed and you can use getActiveRange()
to retrieve the correct row.
好消息&恐怕这是个坏消息.
Good news & Bad news, I'm afraid.
您可以使用可安装的更改触发器来获取收到有关行删除的通知. (更改的完整列表为EDIT,INSERT_ROW,INSERT_COLUMN, REMOVE_ROW ,REMOVE_COLUMN,INSERT_GRID,REMOVE_GRID,FORMAT或OTHER).
You can use an installable Change trigger to get notified about row deletions. (The full list of changes is EDIT, INSERT_ROW, INSERT_COLUMN, REMOVE_ROW, REMOVE_COLUMN, INSERT_GRID, REMOVE_GRID, FORMAT, or OTHER).
坏消息是该事件不会告诉您更改了,因此,如果您希望跟踪名册上的更改,则需要自己跟踪更改.
The bad news is that the event does not tell you what changed, so if you wish to track changes to a roster, you'll need to do that by keeping track of changes yourself.
来自Google问题跟踪器的相关问题:
Related issues from Google's issue tracker:
- SpreadSheet onChange()触发事件参数应该更有用
- 电子表格onChange()getActiveRange()总是屈服于A1 [FIXED]
- INSERT_ROW撤消未更改类型REMOVE_ROW
- SpreadSheet onChange() trigger event parameter should be more useful
- Spreadsheet onChange() getActiveRange() always yields to A1 [FIXED]
- INSERT_ROW Undo is not changeType REMOVE_ROW
这篇关于如何在Google Spreadsheet中记录删除事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!