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シートの保護です。