Enum ProtectionType

  • ProtectionType is an enumeration used to specify parts of a spreadsheet that can be protected from edits.

  • Enums are called using their parent class, name, and property, for example,SpreadsheetApp.ProtectionType.RANGE.

  • ProtectionType has two properties:RANGE for range protection andSHEET for sheet protection.

ProtectionType

An enumeration representing the parts of a spreadsheet that can be protected from edits.

To call an enum, you call its parent class, name, and property. For example,SpreadsheetApp.ProtectionType.RANGE.

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

Properties

PropertyTypeDescription
RANGEEnumProtection for a range.
SHEETEnumProtection for a sheet.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.