API Reference
Cmdlet
Compare-OfficeExcelRange
Compares two Excel worksheets or ranges and returns cell-level differences.
Remarks
Compares two Excel worksheets or ranges and returns cell-level differences.
Examples
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:
PathParameters
- IgnoreCase SwitchParameter
- Compare strings case-insensitively.
- InputPath String
- Left workbook path.
- 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 Nullable`1
- Left worksheet index.
- 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 Nullable`1
- Right worksheet index.
- StrictNullEmpty SwitchParameter
- Treat null and empty string values as different.
- TrimStrings SwitchParameter
- 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:
DocumentParameters
- Document ExcelDocument
- Left workbook object.
- 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 Nullable`1
- Left worksheet index.
- RightDocument ExcelDocument
- Optional right workbook object. 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 Nullable`1
- Right worksheet index.
- StrictNullEmpty SwitchParameter
- Treat null and empty string values as different.
- TrimStrings SwitchParameter
- 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:
ContextParameters
- 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 Nullable`1
- Left worksheet index.
- RightDocument ExcelDocument
- Optional right workbook object. 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 Nullable`1
- Right worksheet index.
- StrictNullEmpty SwitchParameter
- Treat null and empty string values as different.
- TrimStrings SwitchParameter
- Compare strings after trimming whitespace.
Outputs
OfficeIMO.Excel.ExcelRangeDifference