# Clear-OfficeExcelRange

Clears values, formulas, styles, and range metadata from an Excel worksheet range.

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: ExcelRangeClear

**Module**

`PSWriteOffice`

**Aliases**

`ExcelRangeClear`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Source**

[ClearOfficeExcelRangeCommand.cs:18](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Excel/ClearOfficeExcelRangeCommand.cs#L18) 

Clears values, formulas, styles, and range metadata from an Excel worksheet range.

## Syntax

```
Clear-OfficeExcelRange
[-All]
[-Comments]
[-ConditionalFormatting]
[-Contents]
[-DataValidations]
[-Formulas]
[-Hyperlinks]
[-Merges]
[-PassThru]
-Range <String>
[-Sheet <String>]
[-SheetIndex <Int32>]
[-Sparklines]
[-Styles]
[-Values]
[<CommonParameters>]
```

[#](#member-abf5c409c6dfc6d60828d5b6)

Parameter set: `Context`

```
Clear-OfficeExcelRange
[-All]
[-Comments]
[-ConditionalFormatting]
[-Contents]
[-DataValidations]
[-Formulas]
[-Hyperlinks]
[-Merges]
[-PassThru]
[-Path] <String>
-Range <String>
[-Sheet <String>]
[-SheetIndex <Int32>]
[-Sparklines]
[-Styles]
[-Values]
[<CommonParameters>]
```

[#](#member-b70ee369023a58d746a5ae26)

Parameter set: `Path`

```
Clear-OfficeExcelRange
[-All]
[-Comments]
[-ConditionalFormatting]
[-Contents]
[-DataValidations]
-Document <ExcelDocument>
[-Formulas]
[-Hyperlinks]
[-Merges]
[-PassThru]
-Range <String>
[-Sheet <String>]
[-SheetIndex <Int32>]
[-Sparklines]
[-Styles]
[-Values]
[<CommonParameters>]
```

[#](#member-40bec0ff41d7276860c48730)

Parameter set: `Document`

## Examples

### Clear cell contents without removing formatting.

```powershell
Clear-OfficeExcelRange -Path .\Report.xlsx -Sheet Staging -Range B2:D20 -Contents -Hyperlinks -Confirm:$false
Get-OfficeExcelRange -Path .\Report.xlsx -Sheet Staging -Range B2:D20 |
    Select-Object Address, Value, Formula
```

Removes values and formulas from the selected range and saves the workbook.

## Parameters

**-All SwitchParameter optional**

Clear all supported cell data and range metadata.

**-Comments SwitchParameter optional**

Clear comments in the selected range.

**-ConditionalFormatting SwitchParameter optionalaliases: ConditionalFormats**

Clear conditional formatting rules that overlap the selected range.

**-Contents SwitchParameter optional**

Clear values and formulas.

**-DataValidations SwitchParameter optionalaliases: Validation, Validations**

Clear data validation rules that overlap the selected range.

**-Formulas SwitchParameter optional**

Clear formulas.

**-Hyperlinks SwitchParameter optional**

Clear hyperlinks that overlap the selected range.

**-Merges SwitchParameter optional**

Clear merged-cell definitions that overlap the selected range.

**-PassThru SwitchParameter optional**

Emit the object created or changed by the command.

**-Range String required**

A1 range to clear.

**-Sheet String optional**

Worksheet name to update. Defaults to the current DSL sheet or the first workbook sheet.

**-SheetIndex Int32 optional**

Worksheet index (0-based) to update. Defaults to the current DSL sheet or the first workbook sheet.

**-Sparklines SwitchParameter optional**

Clear sparklines whose target cells overlap the selected range.

**-Styles SwitchParameter optionalaliases: Formats**

Clear cell style indexes.

**-Values SwitchParameter optional**

Clear literal cell values.

**-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path**

Workbook path to update.

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

Workbook to update outside the DSL context.

## 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:1DE3BAF3D85284BF0D7955536DE73380F740BBBE77CC05F7A2AD3B6FCDB1013D -->
