Enum ProtectionType

ProtectionType

Một bảng liệt kê thể hiện các phần của bảng tính có thể được bảo vệ khỏi nội dung chỉnh sửa.

Để gọi một enum, bạn phải gọi lớp, tên và thuộc tính gốc của lớp đó. Ví dụ: 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();
}

Thuộc tính

Tài sảnLoạiNội dung mô tả
RANGEEnumBảo vệ một dải ô.
SHEETEnumBảo vệ trang tính.