自Google Spreadsheets上周更新以来,此代码已无法正常运行。只有当用户的ENTERS数据,时间戳出现时,当用户PASTE数据时,才会发生任何事情。
这是我们使用的代码:
function onEditSwapsheet(e) {
var s = e.source.getActiveSheet(),
sheets = ["5B","10B","15B","20B","25B","30B","35B","40B","50B","60B","70B","80B","90B","100B" ],
watchCols = [6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110,],
offsetCol = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,],
sheetInd = sheets.indexOf(s.getName()),
colInd = watchCols.indexOf(e.range.columnStart);
if (sheetInd === -1 || colInd === -1 ) return;
e.range.offset(0, offsetCol[colInd])
.setValue(!e.value ? null : Utilities.formatDate(new Date(), "GMT+0100", "HH:mm dd/MM"))
}