Cmdlet
Compare-OfficeExcelRange
Compares two Excel worksheets or ranges and returns cell-level differences.
Syntax
Compare-OfficeExcelRange
[-IgnoreCase]
[-LeftRange <String>]
[-LeftSheet <String>]
[-LeftSheetIndex <Int32>]
[-Path] <String>
[-RightPath <String>]
[-RightRange <String>]
[-RightSheet <String>]
[-RightSheetIndex <Int32>]
[-StrictNullEmpty]
[-TrimStrings]
[<CommonParameters>]#Parameter set:
PathCompare-OfficeExcelRange
-Document <ExcelDocument>
[-IgnoreCase]
[-LeftRange <String>]
[-LeftSheet <String>]
[-LeftSheetIndex <Int32>]
[-RightDocument <ExcelDocument>]
[-RightRange <String>]
[-RightSheet <String>]
[-RightSheetIndex <Int32>]
[-StrictNullEmpty]
[-TrimStrings]
[<CommonParameters>]#Parameter set:
DocumentCompare-OfficeExcelRange
[-IgnoreCase]
[-LeftRange <String>]
[-LeftSheet <String>]
[-LeftSheetIndex <Int32>]
[-RightDocument <ExcelDocument>]
[-RightRange <String>]
[-RightSheet <String>]
[-RightSheetIndex <Int32>]
[-StrictNullEmpty]
[-TrimStrings]
[<CommonParameters>]#Parameter set:
ContextExamples
Compare current and expected ranges before publishing.
$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.
Parameters
- -IgnoreCase SwitchParameter
- Compare strings case-insensitively.
- -LeftRange String
- Left A1 range. Defaults to the left worksheet used range.
- -LeftSheet String
- Left worksheet name. Defaults to the current sheet in a sheet block, otherwise the first sheet.
- -LeftSheetIndex Int32
- Left worksheet index.
- -Path String
- Left workbook path.
- -RightPath String
- Optional right workbook path. Defaults to the left workbook.
- -RightRange String
- Right A1 range. Defaults to the right worksheet used range.
- -RightSheet String
- Right worksheet name. Defaults to the left sheet.
- -RightSheetIndex Int32
- Right worksheet index.
- -StrictNullEmpty SwitchParameter
- Treat null and empty string values as different.
- -TrimStrings SwitchParameter
- Compare strings after trimming whitespace.
- -Document ExcelDocument
- Left workbook object.
- -RightDocument ExcelDocument
- Optional right workbook object. Defaults to the left 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.