Cmdlet
Compare-OfficeExcelRange
Compares two worksheets or ranges cell by cell.
Syntax
Compare-OfficeExcelRange
[[-DifferencePath] <String>]
[-DifferenceRange <String>]
[-DifferenceSheet <OfficeSheetSelector>]
[-IgnoreCase]
[-Range <String>]
[-ReferencePath] <String>
[-Sheet <OfficeSheetSelector>]
[-StrictNullEmpty]
[-TrimStrings]
[<CommonParameters>]#Parameter set:
PathCompare-OfficeExcelRange
[-DifferenceDocument <ExcelDocument>]
[-DifferenceRange <String>]
[-DifferenceSheet <OfficeSheetSelector>]
[-IgnoreCase]
[-Range <String>]
-ReferenceDocument <ExcelDocument>
[-Sheet <OfficeSheetSelector>]
[-StrictNullEmpty]
[-TrimStrings]
[<CommonParameters>]#Parameter set:
DocumentExamples
Compare a sheet in two versions
Compare-OfficeExcelRange -ReferencePath .\Finance\Budget-v1.xlsx -DifferencePath .\Finance\Budget-v2.xlsx -Sheet Budget |
Select-Object Kind, ReferenceCell, ReferenceValue, DifferenceValueLists the cells of the Budget sheet that differ between two versions of the workbook.
Reconcile two lists in one workbook
$compare = @{
ReferencePath = '.\Finance\Reconciliation-October.xlsx'
Sheet = 'Ledger'
Range = 'A1:F400'
DifferenceSheet = 'Bank'
DifferenceRange = 'A1:F400'
}
Compare-OfficeExcelRange @compare -TrimStrings -IgnoreCase |
Export-OfficeExcel -Path .\Finance\Reconciliation-Differences.xlsx -Title 'Ledger and bank differences'Compares the ledger with the bank statement range by range, ignoring case and stray spaces, and writes the differences to a review workbook.
Parameters
- -DifferencePath String
- Workbook path to compare against.
- -DifferenceRange String
- A1 range containing the comparison values in the difference workbook.
- -DifferenceSheet OfficeSheetSelector
- Worksheet selector in the difference workbook.
- -IgnoreCase SwitchParameter
- Compare strings case-insensitively.
- -Range String
- A1 cell range on the selected worksheet.
- -ReferencePath String
- Path to the workbook containing the reference values.
- -Sheet OfficeSheetSelector
- Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.
- -StrictNullEmpty SwitchParameter
- Treat null and empty string values as different.
- -TrimStrings SwitchParameter
- Compare strings after trimming whitespace.
- -DifferenceDocument ExcelDocument
- Workbook document to compare against.
- -ReferenceDocument ExcelDocument
- Caller-owned workbook containing the reference values.
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.