Cmdlet
Compare-OfficeExcelWorkbook
Compares two workbooks by sheets, cells, formulas, styles, tables, comments, names, and worksheet metadata.
Syntax
Compare-OfficeExcelWorkbook [-DifferencePath] <String> [-MaxDifferences <Int32>] [-Path] <String> [-SkipCells] [-SkipCellStyles] [-SkipComments] [-SkipNamedRanges] [-SkipTables] [-SkipWorksheetMetadata] [<CommonParameters>]#Parameter set:
PathCompare-OfficeExcelWorkbook -DifferenceDocument <ExcelDocument> -Document <ExcelDocument> [-MaxDifferences <Int32>] [-SkipCells] [-SkipCellStyles] [-SkipComments] [-SkipNamedRanges] [-SkipTables] [-SkipWorksheetMetadata] [<CommonParameters>]#Parameter set:
DocumentExamples
Compare two generated workbooks before publishing a refreshed report.
$diff = Compare-OfficeExcelWorkbook -Path .\Expected.xlsx -DifferencePath .\Actual.xlsx -MaxDifferences 500
if (-not $diff.AreEqual) {
$diff.Differences |
Sort-Object Category,SheetName,Address |
Format-Table Category,SheetName,Address,Message,LeftValue,RightValue
}Uses OfficeIMO's reusable workbook diff engine and includes structural metadata by default, not just visible cell values.
Parameters
- -DifferencePath String
- Workbook path to compare against.
- -MaxDifferences Int32
- Maximum number of differences to report.
- -Path String
- Workbook path.
- -SkipCells SwitchParameter
- Skip visible cell value and formula comparison.
- -SkipCellStyles SwitchParameter
- Skip style-index comparison for used cells.
- -SkipComments SwitchParameter
- Skip legacy and threaded comment comparison.
- -SkipNamedRanges SwitchParameter
- Skip workbook and sheet-scoped named-range comparison.
- -SkipTables SwitchParameter
- Skip table metadata comparison.
- -SkipWorksheetMetadata SwitchParameter
- Skip worksheet view, validation, and filter metadata comparison.
- -DifferenceDocument ExcelDocument
- Workbook document to compare against.
- -Document ExcelDocument
- Workbook document.
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.