Class PageProtection
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
पेजसुरक्षा
अब काम नहीं करता. Google Sheets के नए वर्शन में बनाई गई स्प्रेडशीट के लिए, ज़्यादा बेहतर Protection
क्लास का इस्तेमाल करें. हालांकि, इस क्लास को बंद कर दिया गया है, लेकिन यह Sheets के पुराने वर्शन के साथ काम करने के लिए उपलब्ध है.
Google Sheets के पुराने वर्शन में, सुरक्षित की गई शीट को ऐक्सेस करना और उनमें बदलाव करना.
ऐसे तरीके जो अब इस्तेमाल में नहीं हैं
तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
addUser(email)
| void | अगर शीट सुरक्षित है, तो यह फ़ंक्शन उस उपयोगकर्ता को उन उपयोगकर्ताओं की सूची में जोड़ता है जो शीट में बदलाव कर सकते हैं. |
getUsers()
| String[] | यह फ़ंक्शन, उन उपयोगकर्ताओं के ईमेल पतों की सूची दिखाता है जिनके पास इस शीट में बदलाव करने का ऐक्सेस है. |
isProtected()
| Boolean | इससे पता चलता है कि शीट को सुरक्षित करने की सुविधा चालू है या नहीं. |
removeUser(user)
| void | इस फ़ंक्शन का इस्तेमाल करके, किसी उपयोगकर्ता को उन उपयोगकर्ताओं की सूची से हटाया जा सकता है जिनके पास शीट में बदलाव करने की अनुमति है. |
setProtected(protection)
| void | इस विकल्प से, शीट के लिए सुरक्षा की स्थिति सेट की जाती है. |
ऐसे तरीके जो अब इस्तेमाल में नहीं हैं
addUser(email)
अब काम नहीं करता. यह फ़ंक्शन अब काम नहीं करता है. इसलिए, इसका इस्तेमाल नई स्क्रिप्ट में नहीं किया जाना चाहिए.
अगर शीट सुरक्षित है, तो यह फ़ंक्शन उस उपयोगकर्ता को उन उपयोगकर्ताओं की सूची में जोड़ता है जो शीट में बदलाव कर सकते हैं.
// 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);
पैरामीटर
नाम | टाइप | ब्यौरा |
email | String | जोड़े जाने वाले उपयोगकर्ता का ईमेल पता. |
इन्हें भी देखें
getUsers()
अब काम नहीं करता. यह फ़ंक्शन अब काम नहीं करता है. इसलिए, इसका इस्तेमाल नई स्क्रिप्ट में नहीं किया जाना चाहिए.
यह फ़ंक्शन, उन उपयोगकर्ताओं के ईमेल पतों की सूची दिखाता है जिनके पास इस शीट में बदलाव करने का ऐक्सेस है.
अगर शीट को सुरक्षित रखने की सुविधा बंद है, तो इस कॉल से मिली वैल्यू का कोई मतलब नहीं है.
वापसी का टिकट
String[]
— उन उपयोगकर्ताओं के ईमेल पतों की एक सूची जिनके पास इस शीट में बदलाव करने का ऐक्सेस है.
isProtected()
अब काम नहीं करता. यह फ़ंक्शन अब काम नहीं करता है. इसलिए, इसका इस्तेमाल नई स्क्रिप्ट में नहीं किया जाना चाहिए.
इससे पता चलता है कि शीट को सुरक्षित करने की सुविधा चालू है या नहीं.
// Determine whether or not sheet protection is enabled
const sheet = SpreadsheetApp.getActiveSheet();
const permissions = sheet.getSheetProtection();
const isProtected = permissions.isProtected();
वापसी का टिकट
Boolean
— इससे पता चलता है कि शीट को सुरक्षित करने की सुविधा चालू है या नहीं.
इन्हें भी देखें
removeUser(user)
अब काम नहीं करता. यह फ़ंक्शन अब काम नहीं करता है. इसलिए, इसका इस्तेमाल नई स्क्रिप्ट में नहीं किया जाना चाहिए.
इस फ़ंक्शन का इस्तेमाल करके, किसी उपयोगकर्ता को उन उपयोगकर्ताओं की सूची से हटाया जा सकता है जिनके पास शीट में बदलाव करने की अनुमति है.
// 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);
पैरामीटर
नाम | टाइप | ब्यौरा |
user | String | उस उपयोगकर्ता का ईमेल पता जिसे हटाना है. |
इन्हें भी देखें
setProtected(protection)
अब काम नहीं करता. यह फ़ंक्शन अब काम नहीं करता है. इसलिए, इसका इस्तेमाल नई स्क्रिप्ट में नहीं किया जाना चाहिए.
इस विकल्प से, शीट के लिए सुरक्षा की स्थिति सेट की जाती है.
// Enables sheet protection for this sheet
const sheet = SpreadsheetApp.getActiveSheet();
const permissions = sheet.getSheetProtection();
permissions.setProtected(true);
sheet.setSheetProtection(permissions);
पैरामीटर
नाम | टाइप | ब्यौरा |
protection | Boolean | true शीट की सुरक्षा चालू करने के लिए, false शीट की सुरक्षा बंद करने के लिए. |
इन्हें भी देखें
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-08-13 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-08-13 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThe \u003ccode\u003ePageProtection\u003c/code\u003e class is deprecated and should not be used in new scripts for spreadsheets created in the newer version of Google Sheets.\u003c/p\u003e\n"],["\u003cp\u003eUse the \u003ccode\u003eProtection\u003c/code\u003e class instead for newer Google Sheets for more powerful sheet protection features.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ePageProtection\u003c/code\u003e provides methods to manage access and modifications to protected sheets in the older version of Google Sheets.\u003c/p\u003e\n"],["\u003cp\u003eDespite being deprecated, \u003ccode\u003ePageProtection\u003c/code\u003e remains available for compatibility with older Google Sheets.\u003c/p\u003e\n"],["\u003cp\u003eKey methods include adding/removing users with edit access, checking protection status, and setting protection status.\u003c/p\u003e\n"]]],[],null,["# Class PageProtection\n\nPageProtection\n\n\n**Deprecated.** For spreadsheets created in the newer version of Google Sheets, use the more powerful\n[Protection](/apps-script/reference/spreadsheet/protection) class instead. Although this class is deprecated, it remains available\nfor compatibility with the older version of Sheets.\n\nAccess and modify protected sheets in the older version of Google Sheets. \n\n### Deprecated methods\n\n| Method | Return type | Brief description |\n|----------------------------------------------------|-------------|------------------------------------------------------------------------------|\n| [addUser(email)](#addUser(String)) | `void` | Adds a user to the list of users who can edit the sheet, if it is protected. |\n| [getUsers()](#getUsers()) | `String[]` | Returns a list of the email addresses of the users who can edit this sheet. |\n| [isProtected()](#isProtected()) | `Boolean` | Indicates whether the sheet has sheet protection enabled or not. |\n| [removeUser(user)](#removeUser(String)) | `void` | Removes a user from the list of users who can edit the sheet. |\n| [setProtected(protection)](#setProtected(Boolean)) | `void` | Sets the protection status for the sheet. |\n\nDeprecated methods\n------------------\n\n### `add``User(email)`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nAdds a user to the list of users who can edit the sheet, if it is protected.\n\n```javascript\n// Add the \"user@example.com\" user to the list of users who can edit this sheet\nconst sheet = SpreadsheetApp.getActiveSheet();\nconst permissions = sheet.getSheetProtection();\npermissions.addUser('user@example.com');\npermissions.setProtected(true);\nsheet.setSheetProtection(permissions);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|----------|-------------------------------|\n| `email` | `String` | The email of the user to add. |\n\n#### See also\n\n- [removeUser(user)](#removeUser(String))\n\n*** ** * ** ***\n\n### `get``Users()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nReturns a list of the email addresses of the users who can edit this sheet.\n\nIf sheet protection is disabled, the value returned by this call is meaningless.\n\n#### Return\n\n\n`String[]` --- An array of email addresses of users who can edit this sheet.\n\n*** ** * ** ***\n\n### `is``Protected()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nIndicates whether the sheet has sheet protection enabled or not.\n\n```javascript\n// Determine whether or not sheet protection is enabled\nconst sheet = SpreadsheetApp.getActiveSheet();\nconst permissions = sheet.getSheetProtection();\nconst isProtected = permissions.isProtected();\n```\n\n#### Return\n\n\n`Boolean` --- Whether the sheet has sheet protection enabled or not.\n\n#### See also\n\n- [setProtected(protection)](#setProtected(Boolean))\n\n*** ** * ** ***\n\n### `remove``User(user)`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nRemoves a user from the list of users who can edit the sheet.\n\n```javascript\n// Remove the \"user@example.com\" user to the list of users who can edit this\n// sheet\nconst sheet = SpreadsheetApp.getActiveSheet();\nconst permissions = sheet.getSheetProtection();\npermissions.removeUser('user@example.com');\npermissions.setProtected(true);\nsheet.setSheetProtection(permissions);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|------------------------------------------|\n| `user` | `String` | The email address of the user to remove. |\n\n#### See also\n\n- [addUser(email)](#addUser(String))\n\n*** ** * ** ***\n\n### `set``Protected(protection)`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nSets the protection status for the sheet.\n\n```javascript\n// Enables sheet protection for this sheet\nconst sheet = SpreadsheetApp.getActiveSheet();\nconst permissions = sheet.getSheetProtection();\npermissions.setProtected(true);\nsheet.setSheetProtection(permissions);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------|-----------|-------------------------------------------------------------------------|\n| `protection` | `Boolean` | `true` to enable sheet protection, `false` to disable sheet protection. |\n\n#### See also\n\n- [isProtected()](#isProtected())"]]