Enum ProtectionType
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ProtectionType
การแจกแจงที่แสดงถึงส่วนต่างๆ ของสเปรดชีตที่สามารถป้องกันไม่ให้แก้ไขได้
หากต้องการเรียกใช้ enum ให้เรียกคลาสหลัก ชื่อ และพร็อพเพอร์ตี้ของ enum นั้น เช่น
SpreadsheetApp.ProtectionType.RANGE
// Remove all range protections in the spreadsheet that the user has permission
// to edit.
const ss = SpreadsheetApp.getActive();
const protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE);
for (const protection of protections) {
if (protection.canEdit()) {
protection.remove();
}
}
// Removes sheet protection from the active sheet, if the user has permission to
// edit it.
const sheet = SpreadsheetApp.getActiveSheet();
const protection = sheet.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0];
if (protection?.canEdit()) {
protection.remove();
}
พร็อพเพอร์ตี้
พร็อพเพอร์ตี้ | ประเภท | คำอธิบาย |
RANGE | Enum | การป้องกันช่วง |
SHEET | Enum | การป้องกันชีต |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eProtectionType\u003c/code\u003e is an enum used to specify whether you are working with sheet or range protection in Google Apps Script.\u003c/p\u003e\n"],["\u003cp\u003eIt has two properties: \u003ccode\u003eSHEET\u003c/code\u003e and \u003ccode\u003eRANGE\u003c/code\u003e, that are used with the \u003ccode\u003egetProtections()\u003c/code\u003e method to retrieve the corresponding protections.\u003c/p\u003e\n"],["\u003cp\u003eYou can use \u003ccode\u003eProtectionType\u003c/code\u003e to remove or modify existing protections within your spreadsheet, given the necessary permissions.\u003c/p\u003e\n"]]],[],null,["# Enum ProtectionType\n\nProtectionType\n\nAn enumeration representing the parts of a spreadsheet that can be protected from edits.\n\nTo call an enum, you call its parent class, name, and property. For example, `\nSpreadsheetApp.ProtectionType.RANGE`.\n\n```javascript\n// Remove all range protections in the spreadsheet that the user has permission\n// to edit.\nconst ss = SpreadsheetApp.getActive();\nconst protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE);\nfor (const protection of protections) {\n if (protection.canEdit()) {\n protection.remove();\n }\n}\n``` \n\n```javascript\n// Removes sheet protection from the active sheet, if the user has permission to\n// edit it.\nconst sheet = SpreadsheetApp.getActiveSheet();\nconst protection = sheet.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0];\nif (protection?.canEdit()) {\n protection.remove();\n}\n``` \n\n### Properties\n\n| Property | Type | Description |\n|----------|--------|-------------------------|\n| `RANGE` | `Enum` | Protection for a range. |\n| `SHEET` | `Enum` | Protection for a sheet. |"]]