# Protect-OfficeExcelSheet

Protects the current worksheet. Review available syntax, parameters, pipeline guidance, and reference details in PSWriteOffice API Reference.

Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

[View on GitHub](https://github.com/EvotecIT/OfficeIMO/tree/master/PowerShell/PSWriteOffice) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSWriteOffice/releases/tag/v3.0.5) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSWriteOffice/0.2.0)

Stars **727**

Forks **84**

Open issues **7**

Total downloads **5,275,783**

Release **OfficeIMO-v3.6.2**

Language: C# Updated: 2026-11-24

Cmdlet 

Aliases: ExcelProtect

**Module**

`PSWriteOffice`

**Aliases**

`ExcelProtect`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Source**

[ProtectOfficeExcelSheetCommand.cs:17](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Excel/ProtectOfficeExcelSheetCommand.cs#L17) 

Protects the current worksheet.

## Syntax

```
Protect-OfficeExcelSheet
[-AllowAutoFilter <Boolean>]
[-AllowDeleteColumns <Boolean>]
[-AllowDeleteRows <Boolean>]
[-AllowFormatCells <Boolean>]
[-AllowFormatColumns <Boolean>]
[-AllowFormatRows <Boolean>]
[-AllowInsertColumns <Boolean>]
[-AllowInsertHyperlinks <Boolean>]
[-AllowInsertRows <Boolean>]
[-AllowPivotTables <Boolean>]
[-AllowSelectLockedCells <Boolean>]
[-AllowSelectUnlockedCells <Boolean>]
[-AllowSort <Boolean>]
[-AllowTableEditing]
[-PassThru]
[<CommonParameters>]
```

[#](#method-protect-officeexcelsheet-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-switchparameter-switchparameter)

Parameter set: `Context`

```
Protect-OfficeExcelSheet
[-AllowAutoFilter <Boolean>]
[-AllowDeleteColumns <Boolean>]
[-AllowDeleteRows <Boolean>]
[-AllowFormatCells <Boolean>]
[-AllowFormatColumns <Boolean>]
[-AllowFormatRows <Boolean>]
[-AllowInsertColumns <Boolean>]
[-AllowInsertHyperlinks <Boolean>]
[-AllowInsertRows <Boolean>]
[-AllowPivotTables <Boolean>]
[-AllowSelectLockedCells <Boolean>]
[-AllowSelectUnlockedCells <Boolean>]
[-AllowSort <Boolean>]
[-AllowTableEditing]
-Document <ExcelDocument>
[-PassThru]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]
```

[#](#method-protect-officeexcelsheet-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-boolean-switchparameter-exceldocument-switchparameter-string-int32)

Parameter set: `Document`

## Examples

### Protect the active sheet with default options.

```powershell
ExcelSheet 'Data' { Protect-OfficeExcelSheet }
```

Enables worksheet protection.

## Parameters

**-AllowAutoFilter Boolean optional**

Allow AutoFilter.

**-AllowDeleteColumns Boolean optional**

Allow deleting columns.

**-AllowDeleteRows Boolean optional**

Allow deleting rows.

**-AllowFormatCells Boolean optional**

Allow formatting cells.

**-AllowFormatColumns Boolean optional**

Allow formatting columns.

**-AllowFormatRows Boolean optional**

Allow formatting rows.

**-AllowInsertColumns Boolean optional**

Allow inserting columns.

**-AllowInsertHyperlinks Boolean optional**

Allow inserting hyperlinks.

**-AllowInsertRows Boolean optional**

Allow inserting rows.

**-AllowPivotTables Boolean optional**

Allow PivotTables.

**-AllowSelectLockedCells Boolean optional**

Allow selecting locked cells.

**-AllowSelectUnlockedCells Boolean optional**

Allow selecting unlocked cells.

**-AllowSort Boolean optional**

Allow sorting.

**-AllowTableEditing SwitchParameter optional**

Allow common protected-table workflows: selecting cells, inserting rows, sorting, and filtering.

**-PassThru SwitchParameter optional**

Emit the worksheet after protection.

**-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document**

Workbook to operate on outside the DSL context.

**-Sheet String optionalsets: Document**

Worksheet name when using Document.

**-SheetIndex Int32 optionalsets: Document**

Worksheet index (0-based) when using Document.

## Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see [about_CommonParameters](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:9E5A1C1C31BEDCCB285B9526D4BCC05A0F5CD1261E07CE87CB52AB9057944183 -->
