Enum ProtectionType

保护类型

一个枚举,表示可以保护工作表中哪些部分免遭修改。

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

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

属性

属性类型说明
RANGEEnum对某个范围的保护。
SHEETEnum对工作表的保护。