答案 0 :(得分:1)
保护批准的行
function protectApprovedRows() {
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('name');
var sr=2;
var sc=1;
var vs=sh.getRange(sr,sc,sh.getLastRow()-sr+1,sh.getLastColumn()-sc+1).getValues();
var me = Session.getEffectiveUser();
vs.forEach(function(r,i){
if(r[4]=="Approved") {
var protection=sh.getRange(i+sr,sc,1,sh.getLastColumn()-sc+1).protect();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}
});
}