我想每周更新给定的日期[重置日]。在本次更新期间,如果每周出勤率也将重置为 0,并且如果其值小于 2,则出勤率将减少 8 分。
示例初始表
Name | Attendance Point | Weekly Attendance | Reset Day
--------------------------------------------------------------
Jack | 12 | 0 | 13/09/2018
Jacob | 23 | 0 |
Emily | 12 | 1 |
Rick | 11 | 2 |
Rob | 21 | 3 |
所需更新
Name | Attendance Point | Weekly Attendance | Reset Day
--------------------------------------------------------------
Jack | 4 | 0 | 20/09/2018
Jacob | 15 | 0 |
Emily | 4 | 0 |
Rick | 11 | 0 |
Rob | 21 | 0 |
样品基片
https://docs.google.com/spreadsheets/d/1khPC5r2p0b1srsEGka3fl-GAl6nHACaVR0Cf31cqA1o/edit?usp=sharing
提前致谢
function resetCells() {
var ss = SpreadsheetApp.getActive().getSheetByName('Sheet');
var range = ss.getDataRange().offset(1, 0, ss.getLastRow() - 1);
var values = range.getValues().map(function(e) {
return e[0] ? [false, e[1], e[2], e[3], e[4] + 1, e[5]] : e;
});
range.setValues(values);
}
更新功能
function weekDays() {
var ss = SpreadsheetApp.getActive().getSheetByName('Sheet').getRange('F2').setValue(new Date())
}