列舉項目,代表試算表中可禁止編輯的部分。
如要呼叫列舉,您可以呼叫其父項類別、名稱和屬性。例如
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(); }
屬性
屬性 | 類型 | 說明 |
---|---|---|
RANGE | Enum | 保護範圍 |
SHEET | Enum | 工作表保護: |