[英]removal of double cell protection google sheets
我有一个脚本可以在添加条目后保护单元格。 删除条目后,它会禁用保护。 不幸的是,如果有人在工作表单元格中覆盖,它会保护两次。 删除条目时,它只会删除一种保护。 有什么办法让它取消所有保护吗?
function findProtectionFromRange(range) {
let row = range.getRow();
let col = range.getColumn();
let protections = range.getSheet().getProtections(SpreadsheetApp.ProtectionType.RANGE);
return protections.find((protection) => {
let protectionRange = protection.getRange();
if (row === protectionRange.getRow() && col === protectionRange.getColumn()) {
return protection;
}
return null;
});
}
function onEdit(e) {
let range = e.range;
let protection = findProtectionFromRange(range);
if (e.value === undefined && protection) {
protection.remove();
return;
好吧,您有一个脚本可以在输入值后保护单元格,对吗?
解决方法很简单,那么在保护之前先检查cell是否已经被保护。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.