【发布时间】:2023-01-10 14:10:48
【问题描述】:
这是我到目前为止运行的代码:
function onEdit(e){
let protection = e.range.protect();
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}
这会在单元格被编辑后锁定它们,但是即使在单元格被清空后,单元格仍然锁定到只有一个编辑器。我怎样才能做出这个改变,这样如果它再次为空,它就会解除自我保护?
非常感谢!
【问题讨论】:
-
如果其他人有这个问题=这里是答案。
-
}function onEdit(e){ if (e.value == null){ let prot = SpreadsheetApp.getActiveSheet().getProtections(SpreadsheetApp.ProtectionType.RANGE); for (let i in prot){ if (prot[i].getRange().getA1Notation() == e.range.getA1Notation()) prot[i].remove(); } } else { 让保护 = e.range.protect(); protection.removeEditors(protection.getEditors());如果 (protection.canDomainEdit()) protection.setDomainEdit(false); } }
-
这是缺少的代码
标签: google-sheets