Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Compare-OfficeExcelWorkbook

Aliases: ExcelWorkbookCompare
Module PSWriteOffice
Aliases
ExcelWorkbookCompare
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Management.Automation.PSObject

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: Path
Compare-OfficeExcelWorkbook -DifferenceDocument <ExcelDocument> -Document <ExcelDocument> [-MaxDifferences <Int32>] [-SkipCells] [-SkipCellStyles] [-SkipComments] [-SkipNamedRanges] [-SkipTables] [-SkipWorksheetMetadata] [<CommonParameters>]
#
Parameter set: Document

Examples

Authored help example

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 requiredposition: 1sets: Path
Workbook path to compare against.
-MaxDifferences Int32 optional
Maximum number of differences to report.
-Path String requiredposition: 0aliases: InputPath, ReferencePathsets: Path
Workbook path.
-SkipCells SwitchParameter optional
Skip visible cell value and formula comparison.
-SkipCellStyles SwitchParameter optional
Skip style-index comparison for used cells.
-SkipComments SwitchParameter optional
Skip legacy and threaded comment comparison.
-SkipNamedRanges SwitchParameter optional
Skip workbook and sheet-scoped named-range comparison.
-SkipTables SwitchParameter optional
Skip table metadata comparison.
-SkipWorksheetMetadata SwitchParameter optional
Skip worksheet view, validation, and filter metadata comparison.
-DifferenceDocument ExcelDocument requiredsets: Document
Workbook document to compare against.
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
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.