# SheetProtection Class

> SheetProtection class in the Node.js JavaScript API: Worksheet-bound editing protection, using the same locked-cell styles as Excel import/export.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Path:** TX Sheet Control > API Reference > JavaScript API > Node.js Server > SheetProtection Class
- **893 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/llms-full.txt

---

Worksheet-bound editing protection, using the same locked-cell styles as Excel import/export.

Package: `@txtextcontrol/tx-sheet-control-server`. Version: **2.0.0**.

Related workbook object-model type, returned through the server control. Obtain it from its owning workbook or collection; it is not a required browser-package import.

### Constructor

```javascript
new SheetProtection(sheet)
```

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `sheet` | `Worksheet` | No | Value matching sheet's declared type and the owning object's validation rules. |

Returns: `SheetProtection`.

### Members

#### Properties

| Property | Description |
|---|---|
| [isProtected](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/isprotected-property/llms-full.txt) | The isProtected value of SheetProtection. |
| [settings](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/settings-property/llms-full.txt) | The settings value of SheetProtection. |
| [sheet](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/sheet-property/llms-full.txt) | The sheet value of SheetProtection. |

#### Methods

| Method | Description |
|---|---|
| [canSelect](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/canselect-method/llms-full.txt) | Checks protected selection permissions for a rectangle without allocating blank cells. |
| [protect](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/protect-method/llms-full.txt) | Protects the worksheet. Passwords use Excel's legacy verifier and never enter saved JSON as clear text. |
| [unprotect](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/unprotect-method/llms-full.txt) | Removes protection after verifying its password, including modern imported Excel verifiers. |

### Examples

Use a fresh workbook. Create and format the sample data, apply this API and retain the returned document or result in your application. In the browser pass editor.workbook; in Node.js pass the server control.

```javascript
function createSheetProtectionReport(control) {
    const book = control.workbook;
    const sheet = book.sheets.at(0);
    sheet.cell('A1').setText('October invoice');
    sheet.cell('A1').format({
        fontFamily: 'Liberation Sans',
        fontSize: 16,
        bold: true,
        textColor: '#ffffff',
        fillColor: '#163b63',
    });

    sheet.columns.at(0).setWidth({ pixels: 240 });
    sheet.range('B8:B9').setValues([[120], [80]]);
    sheet.cell('B10').setFormula('=SUM(B8:B9)');
    sheet.range('B8:B10').format({ numberFormatCode: '#,##0.00', fontSize: 11 });
    sheet.protection.protect({ password: 'sample-edit-password' });
    return sheet;
}
```

### See Also

- [JavaScript Node.js Server API](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/llms-full.txt)
- [Worksheet Protection](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/protection/llms-full.txt)

---

## In This Section

- [SheetProtection.canSelect Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/canselect-method/llms-full.txt): SheetProtection.canSelect method in the Node.js JavaScript API: Checks protected selection permissions for a rectangle without allocating blank cells.
- [SheetProtection.isProtected Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/isprotected-property/llms-full.txt): SheetProtection.isProtected property in the TX Sheet Control JavaScript API for Node.js, with its type boolean and a JavaScript example.
- [SheetProtection.protect Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/protect-method/llms-full.txt): SheetProtection.protect method in the TX Sheet Control JavaScript API for Node.js: Protects the worksheet. Includes the syntax and a JavaScript example.
- [SheetProtection.settings Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/settings-property/llms-full.txt): SheetProtection.settings property in the TX Sheet Control JavaScript API for Node.js, with its type ProtectionState and a JavaScript example.
- [SheetProtection.sheet Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/sheet-property/llms-full.txt): SheetProtection.sheet property in the TX Sheet Control JavaScript API for Node.js, with its type Worksheet and a JavaScript example.
- [SheetProtection.unprotect Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/unprotect-method/llms-full.txt): SheetProtection.unprotect method in the Node.js JavaScript API: Removes protection after verifying its password, including modern imported Excel verifiers.

---

## Nearby

- **Previous:** [SheetPrint.sheet Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprint/sheet-property/llms-full.txt)
- **Next:** [SheetProtection.canSelect Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/sheetprotection/canselect-method/llms-full.txt)
