Send feedback
Enum ProtectionType
Stay organized with collections
Save and categorize content based on your preferences.
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 .
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 ();
}
Properties
Property Type Description
RANGE
Enum
Protection for a range.
SHEET
Enum
Protection for a sheet.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[],[]]