Enum ProtectionType

ProtectionType

一个枚举,表示电子表格中可以保护其免遭编辑的部分。

如需调用枚举,您需要调用其父类、名称和属性。例如 SpreadsheetApp.ProtectionType.RANGE

// Remove all range protections in the spreadsheet that the user has permission to edit.
var ss = SpreadsheetApp.getActive();
var protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE);
for (var i = 0; i < protections.length; i++) {
  var protection = protections[i];
  if (protection.canEdit()) {
    protection.remove();
  }
}
// Removes sheet protection from the active sheet, if the user has permission to edit it.
var sheet = SpreadsheetApp.getActiveSheet();
var protection = sheet.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0];
if (protection && protection.canEdit()) {
  protection.remove();
}

属性

属性类型说明
RANGEEnum在一定范围内提供保护。
SHEETEnum工作表保护。