# Protection Class

> Protection class in the TX Sheet Control .NET API: Enforced worksheet editing permissions using the same locked-cell styles as the JavaScript editor.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Namespace:** `TXTextControl.TXSheetControl.Server`
- **Package:** `TXTextControl.TXSheetControl.Server` (assembly `TXTextControl.TXSheetControl.Api.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Package:** `TXTextControl.TXSheetControl.Blazor` (assembly `TXTextControl.TXSheetControl.Api.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Inherits:** `TXTextControl.TXSheetControl.Server.DocumentObject`
- **Path:** TX Sheet Control > API Reference > .NET API > TXTextControl.TXSheetControl.Server > Protection Class
- **796 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/llms-full.txt

---

Enforced worksheet editing permissions using the same locked-cell styles as the JavaScript editor.

### Syntax

```csharp
public class Protection
```

### Members

#### Methods

| Method | Description |
|---|---|
| [CanSelectAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/canselectasync-method/llms-full.txt) | Checks whether protected-sheet permissions permit selecting a rectangle. |
| [GetSettingsAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/getsettingsasync-method/llms-full.txt) | Reads detached protection metadata without exposing a clear-text password. |
| [ProtectAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/protectasync-method/llms-full.txt) | Enables protection with explicitly granted editing permissions. |
| [UnprotectAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/unprotectasync-method/llms-full.txt) | Verifies the password before removing protection; use outside a synchronous workbook batch. |

### Examples

Build a small report using this document API and return its PDF bytes. Pass a live control with a fresh workbook; the caller owns its lifetime.

```csharp
using TXTextControl.TXSheetControl.Server;

async Task<byte[]> CreateProtectionReportAsync(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    await sheet.Cell("B8").SetValueAsync(120);
    await sheet.Cell("B9").SetValueAsync(80);
    await sheet.Cell("B10").SetFormulaAsync("=SUM(B8:B9)");

    var protection = sheet.Protection;
    await protection.ProtectAsync(new ProtectionOptions { Password = "sample-edit-password" });
    return await control.SaveAsync(StreamType.PDF);
}
```

### See Also

- [TXTextControl.TXSheetControl.Server Namespace](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/llms-full.txt)
- [Worksheet Protection](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/protection/llms-full.txt)

---

## In This Section

- [Protection.CanSelectAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/canselectasync-method/llms-full.txt): Protection.CanSelectAsync method in the TX Sheet Control .NET API: Checks whether protected-sheet permissions permit selecting a rectangle.
- [Protection.GetSettingsAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/getsettingsasync-method/llms-full.txt): Protection.GetSettingsAsync method in the TX Sheet Control .NET API: Reads detached protection metadata without exposing a clear-text password.
- [Protection.ProtectAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/protectasync-method/llms-full.txt): Protection.ProtectAsync method in the TX Sheet Control .NET API: Enables protection with explicitly granted editing permissions.
- [Protection.UnprotectAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/unprotectasync-method/llms-full.txt): Protection.UnprotectAsync method in the TX Sheet Control .NET API: Verifies the password before removing protection; use outside a synchronous workbook batch.

---

## Nearby

- **Previous:** [PictureSource.MimeType Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/picturesource/mimetype-property/llms-full.txt)
- **Next:** [Protection.CanSelectAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/protection/canselectasync-method/llms-full.txt)
