API Reference

Cmdlet

Compare-OfficeExcelRange

Aliases: Compare-OfficeExcelSheet, ExcelCompare
Namespace PSWriteOffice
Aliases
Compare-OfficeExcelSheet ExcelCompare
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
OfficeIMO.Excel.ExcelRangeDifference

Compares two Excel worksheets or ranges and returns cell-level differences.

Remarks

Compares two Excel worksheets or ranges and returns cell-level differences.

Examples

Authored help example

Compare current and expected ranges before publishing.

PS>


$differences = Compare-OfficeExcelRange -Path .\Report.xlsx -LeftSheet Current -RightSheet Expected -LeftRange A1:D20 -RightRange A1:D20 -TrimStrings -IgnoreCase
            if ($differences) {
                $differences | Export-Csv -Path .\RangeDifferences.csv -NoTypeInformation
            }
        

Compares two ranges and exports cell-level differences when the workbook does not match the expected sheet.

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

Compare-OfficeExcelRange [-IgnoreCase] -InputPath <String> [-LeftRange <String>] [-LeftSheet <String>] [-LeftSheetIndex <Nullable`1>] [-RightPath <String>] [-RightRange <String>] [-RightSheet <String>] [-RightSheetIndex <Nullable`1>] [-StrictNullEmpty] [-TrimStrings] [<CommonParameters>]
#
Parameter set: Path

Parameters

IgnoreCase SwitchParameter optionalposition: namedpipeline: False
Compare strings case-insensitively.
InputPath String requiredposition: 0pipeline: Falsealiases: FilePath, LeftPath, Path
Left workbook path.
LeftRange String optionalposition: namedpipeline: False
Left A1 range. Defaults to the left worksheet used range.
LeftSheet String optionalposition: namedpipeline: False
Left worksheet name. Defaults to the current sheet in a sheet block, otherwise the first sheet.
LeftSheetIndex Nullable`1 optionalposition: namedpipeline: False
Left worksheet index.
RightPath String optionalposition: namedpipeline: False
Optional right workbook path. Defaults to the left workbook.
RightRange String optionalposition: namedpipeline: False
Right A1 range. Defaults to the right worksheet used range.
RightSheet String optionalposition: namedpipeline: False
Right worksheet name. Defaults to the left sheet.
RightSheetIndex Nullable`1 optionalposition: namedpipeline: False
Right worksheet index.
StrictNullEmpty SwitchParameter optionalposition: namedpipeline: False
Treat null and empty string values as different.
TrimStrings SwitchParameter optionalposition: namedpipeline: False
Compare strings after trimming whitespace.

Outputs

OfficeIMO.Excel.ExcelRangeDifference

Compare-OfficeExcelRange -Document <ExcelDocument> [-IgnoreCase] [-LeftRange <String>] [-LeftSheet <String>] [-LeftSheetIndex <Nullable`1>] [-RightDocument <ExcelDocument>] [-RightRange <String>] [-RightSheet <String>] [-RightSheetIndex <Nullable`1>] [-StrictNullEmpty] [-TrimStrings] [<CommonParameters>]
#
Parameter set: Document

Parameters

Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Left workbook object.
IgnoreCase SwitchParameter optionalposition: namedpipeline: False
Compare strings case-insensitively.
LeftRange String optionalposition: namedpipeline: False
Left A1 range. Defaults to the left worksheet used range.
LeftSheet String optionalposition: namedpipeline: False
Left worksheet name. Defaults to the current sheet in a sheet block, otherwise the first sheet.
LeftSheetIndex Nullable`1 optionalposition: namedpipeline: False
Left worksheet index.
RightDocument ExcelDocument optionalposition: namedpipeline: False
Optional right workbook object. Defaults to the left workbook.
RightRange String optionalposition: namedpipeline: False
Right A1 range. Defaults to the right worksheet used range.
RightSheet String optionalposition: namedpipeline: False
Right worksheet name. Defaults to the left sheet.
RightSheetIndex Nullable`1 optionalposition: namedpipeline: False
Right worksheet index.
StrictNullEmpty SwitchParameter optionalposition: namedpipeline: False
Treat null and empty string values as different.
TrimStrings SwitchParameter optionalposition: namedpipeline: False
Compare strings after trimming whitespace.

Outputs

OfficeIMO.Excel.ExcelRangeDifference

Compare-OfficeExcelRange [-IgnoreCase] [-LeftRange <String>] [-LeftSheet <String>] [-LeftSheetIndex <Nullable`1>] [-RightDocument <ExcelDocument>] [-RightRange <String>] [-RightSheet <String>] [-RightSheetIndex <Nullable`1>] [-StrictNullEmpty] [-TrimStrings] [<CommonParameters>]
#
Parameter set: Context

Parameters

IgnoreCase SwitchParameter optionalposition: namedpipeline: False
Compare strings case-insensitively.
LeftRange String optionalposition: namedpipeline: False
Left A1 range. Defaults to the left worksheet used range.
LeftSheet String optionalposition: namedpipeline: False
Left worksheet name. Defaults to the current sheet in a sheet block, otherwise the first sheet.
LeftSheetIndex Nullable`1 optionalposition: namedpipeline: False
Left worksheet index.
RightDocument ExcelDocument optionalposition: namedpipeline: False
Optional right workbook object. Defaults to the left workbook.
RightRange String optionalposition: namedpipeline: False
Right A1 range. Defaults to the right worksheet used range.
RightSheet String optionalposition: namedpipeline: False
Right worksheet name. Defaults to the left sheet.
RightSheetIndex Nullable`1 optionalposition: namedpipeline: False
Right worksheet index.
StrictNullEmpty SwitchParameter optionalposition: namedpipeline: False
Treat null and empty string values as different.
TrimStrings SwitchParameter optionalposition: namedpipeline: False
Compare strings after trimming whitespace.

Outputs

OfficeIMO.Excel.ExcelRangeDifference