Stay organized with collections Save and categorize content based on your preferences.
PageProtectionDeprecated. For spreadsheets created in the newer version of Google Sheets, use the more powerful Protection
class instead. Although this class is deprecated, it remains available for compatibility with the older version of Sheets.
Access and modify protected sheets in the older version of Google Sheets.
Deprecated methods Method Return type Brief descriptionaddUser(email)
void
Adds a user to the list of users who can edit the sheet, if it is protected. getUsers()
String[]
Returns a list of the email addresses of the users who can edit this sheet. isProtected()
Boolean
Indicates whether the sheet has sheet protection enabled or not. removeUser(user)
void
Removes a user from the list of users who can edit the sheet. setProtected(protection)
void
Sets the protection status for the sheet. Deprecated methods addUser(email)
Deprecated. This function is deprecated and should not be used in new scripts.
Adds a user to the list of users who can edit the sheet, if it is protected.
// Add the "user@example.com" user to the list of users who can edit this sheet const sheet = SpreadsheetApp.getActiveSheet(); const permissions = sheet.getSheetProtection(); permissions.addUser('user@example.com'); permissions.setProtected(true); sheet.setSheetProtection(permissions);Parameters Name Type Description
email
String
The email of the user to add. See also
getUsers()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns a list of the email addresses of the users who can edit this sheet.
If sheet protection is disabled, the value returned by this call is meaningless.
ReturnString[]
— An array of email addresses of users who can edit this sheet.
isProtected()
Deprecated. This function is deprecated and should not be used in new scripts.
Indicates whether the sheet has sheet protection enabled or not.
// Determine whether or not sheet protection is enabled const sheet = SpreadsheetApp.getActiveSheet(); const permissions = sheet.getSheetProtection(); const isProtected = permissions.isProtected();Return
Boolean
— Whether the sheet has sheet protection enabled or not.
removeUser(user)
Deprecated. This function is deprecated and should not be used in new scripts.
Removes a user from the list of users who can edit the sheet.
// Remove the "user@example.com" user to the list of users who can edit this // sheet const sheet = SpreadsheetApp.getActiveSheet(); const permissions = sheet.getSheetProtection(); permissions.removeUser('user@example.com'); permissions.setProtected(true); sheet.setSheetProtection(permissions);Parameters Name Type Description
user
String
The email address of the user to remove. See also
setProtected(protection)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets the protection status for the sheet.
// Enables sheet protection for this sheet const sheet = SpreadsheetApp.getActiveSheet(); const permissions = sheet.getSheetProtection(); permissions.setProtected(true); sheet.setSheetProtection(permissions);Parameters Name Type Description
protection
Boolean
true
to enable sheet protection, false
to disable sheet protection. See also
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 2025-08-12 UTC.
[[["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 2025-08-12 UTC."],[[["The `PageProtection` class is deprecated and should not be used in new scripts for spreadsheets created in the newer version of Google Sheets."],["Use the `Protection` class instead for newer Google Sheets for more powerful sheet protection features."],["`PageProtection` provides methods to manage access and modifications to protected sheets in the older version of Google Sheets."],["Despite being deprecated, `PageProtection` remains available for compatibility with older Google Sheets."],["Key methods include adding/removing users with edit access, checking protection status, and setting protection status."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4