API Reference

Cmdlet

Clear-OfficeExcelRange

Aliases: ExcelRangeClear
Namespace PSWriteOffice
Aliases
ExcelRangeClear
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Object

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

Remarks

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

Examples

Authored help example

Clear cell contents without removing formatting.

PS>


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.

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.

Syntax

Clear-OfficeExcelRange [-All] [-Comments] [-ConditionalFormatting] [-Contents] [-DataValidations] [-Formulas] [-Hyperlinks] [-Merges] -Range <String> [-Sheet <String>] [-SheetIndex <Nullable`1>] [-Sparklines] [-Styles] [-Values] [<CommonParameters>]
#
Parameter set: Context

Parameters

All SwitchParameter optionalposition: namedpipeline: False
Clear all supported cell data and range metadata.
Comments SwitchParameter optionalposition: namedpipeline: False
Clear comments in the selected range.
ConditionalFormatting SwitchParameter optionalposition: namedpipeline: Falsealiases: ConditionalFormats
Clear conditional formatting rules that overlap the selected range.
Contents SwitchParameter optionalposition: namedpipeline: False
Clear values and formulas.
DataValidations SwitchParameter optionalposition: namedpipeline: Falsealiases: Validation, Validations
Clear data validation rules that overlap the selected range.
Formulas SwitchParameter optionalposition: namedpipeline: False
Clear formulas.
Hyperlinks SwitchParameter optionalposition: namedpipeline: False
Clear hyperlinks that overlap the selected range.
Merges SwitchParameter optionalposition: namedpipeline: False
Clear merged-cell definitions that overlap the selected range.
Range String requiredposition: namedpipeline: False
A1 range to clear.
Sheet String optionalposition: namedpipeline: False
Worksheet name to update. Defaults to the current DSL sheet or the first workbook sheet.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Worksheet index (0-based) to update. Defaults to the current DSL sheet or the first workbook sheet.
Sparklines SwitchParameter optionalposition: namedpipeline: False
Clear sparklines whose target cells overlap the selected range.
Styles SwitchParameter optionalposition: namedpipeline: Falsealiases: Formats
Clear cell style indexes.
Values SwitchParameter optionalposition: namedpipeline: False
Clear literal cell values.

Outputs

System.Object

Clear-OfficeExcelRange [-All] [-Comments] [-ConditionalFormatting] [-Contents] [-DataValidations] [-Formulas] [-Hyperlinks] -InputPath <String> [-Merges] -Range <String> [-Sheet <String>] [-SheetIndex <Nullable`1>] [-Sparklines] [-Styles] [-Values] [<CommonParameters>]
#
Parameter set: Path

Parameters

All SwitchParameter optionalposition: namedpipeline: False
Clear all supported cell data and range metadata.
Comments SwitchParameter optionalposition: namedpipeline: False
Clear comments in the selected range.
ConditionalFormatting SwitchParameter optionalposition: namedpipeline: Falsealiases: ConditionalFormats
Clear conditional formatting rules that overlap the selected range.
Contents SwitchParameter optionalposition: namedpipeline: False
Clear values and formulas.
DataValidations SwitchParameter optionalposition: namedpipeline: Falsealiases: Validation, Validations
Clear data validation rules that overlap the selected range.
Formulas SwitchParameter optionalposition: namedpipeline: False
Clear formulas.
Hyperlinks SwitchParameter optionalposition: namedpipeline: False
Clear hyperlinks that overlap the selected range.
InputPath String requiredposition: 0pipeline: Falsealiases: FilePath, Path
Workbook path to update.
Merges SwitchParameter optionalposition: namedpipeline: False
Clear merged-cell definitions that overlap the selected range.
Range String requiredposition: namedpipeline: False
A1 range to clear.
Sheet String optionalposition: namedpipeline: False
Worksheet name to update. Defaults to the current DSL sheet or the first workbook sheet.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Worksheet index (0-based) to update. Defaults to the current DSL sheet or the first workbook sheet.
Sparklines SwitchParameter optionalposition: namedpipeline: False
Clear sparklines whose target cells overlap the selected range.
Styles SwitchParameter optionalposition: namedpipeline: Falsealiases: Formats
Clear cell style indexes.
Values SwitchParameter optionalposition: namedpipeline: False
Clear literal cell values.

Outputs

System.Object

Clear-OfficeExcelRange [-All] [-Comments] [-ConditionalFormatting] [-Contents] [-DataValidations] -Document <ExcelDocument> [-Formulas] [-Hyperlinks] [-Merges] -Range <String> [-Sheet <String>] [-SheetIndex <Nullable`1>] [-Sparklines] [-Styles] [-Values] [<CommonParameters>]
#
Parameter set: Document

Parameters

All SwitchParameter optionalposition: namedpipeline: False
Clear all supported cell data and range metadata.
Comments SwitchParameter optionalposition: namedpipeline: False
Clear comments in the selected range.
ConditionalFormatting SwitchParameter optionalposition: namedpipeline: Falsealiases: ConditionalFormats
Clear conditional formatting rules that overlap the selected range.
Contents SwitchParameter optionalposition: namedpipeline: False
Clear values and formulas.
DataValidations SwitchParameter optionalposition: namedpipeline: Falsealiases: Validation, Validations
Clear data validation rules that overlap the selected range.
Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook to update outside the DSL context.
Formulas SwitchParameter optionalposition: namedpipeline: False
Clear formulas.
Hyperlinks SwitchParameter optionalposition: namedpipeline: False
Clear hyperlinks that overlap the selected range.
Merges SwitchParameter optionalposition: namedpipeline: False
Clear merged-cell definitions that overlap the selected range.
Range String requiredposition: namedpipeline: False
A1 range to clear.
Sheet String optionalposition: namedpipeline: False
Worksheet name to update. Defaults to the current DSL sheet or the first workbook sheet.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Worksheet index (0-based) to update. Defaults to the current DSL sheet or the first workbook sheet.
Sparklines SwitchParameter optionalposition: namedpipeline: False
Clear sparklines whose target cells overlap the selected range.
Styles SwitchParameter optionalposition: namedpipeline: Falsealiases: Formats
Clear cell style indexes.
Values SwitchParameter optionalposition: namedpipeline: False
Clear literal cell values.

Outputs

System.Object