API Reference

Cmdlet

Compare-OfficeExcelWorkbook

Aliases: ExcelWorkbookCompare
Namespace 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.

Remarks

Compares two workbooks by sheets, cells, formulas, styles, tables, comments, names, and worksheet metadata.

Examples

Authored help example

Compare two generated workbooks before publishing a refreshed report.

PS>


$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.

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-OfficeExcelWorkbook -DifferencePath <String> -InputPath <String> [-MaxDifferences <Int32>] [-SkipCells] [-SkipCellStyles] [-SkipComments] [-SkipNamedRanges] [-SkipTables] [-SkipWorksheetMetadata] [<CommonParameters>]
#
Parameter set: Path

Parameters

DifferencePath String requiredposition: 1pipeline: False
Workbook path to compare against.
InputPath String requiredposition: 0pipeline: Falsealiases: Path, ReferencePath
Workbook path.
MaxDifferences Int32 optionalposition: namedpipeline: False
Maximum number of differences to report.
SkipCells SwitchParameter optionalposition: namedpipeline: False
Skip visible cell value and formula comparison.
SkipCellStyles SwitchParameter optionalposition: namedpipeline: False
Skip style-index comparison for used cells.
SkipComments SwitchParameter optionalposition: namedpipeline: False
Skip legacy and threaded comment comparison.
SkipNamedRanges SwitchParameter optionalposition: namedpipeline: False
Skip workbook and sheet-scoped named-range comparison.
SkipTables SwitchParameter optionalposition: namedpipeline: False
Skip table metadata comparison.
SkipWorksheetMetadata SwitchParameter optionalposition: namedpipeline: False
Skip worksheet view, validation, and filter metadata comparison.

Outputs

System.Management.Automation.PSObject

Compare-OfficeExcelWorkbook -DifferenceDocument <ExcelDocument> -Document <ExcelDocument> [-MaxDifferences <Int32>] [-SkipCells] [-SkipCellStyles] [-SkipComments] [-SkipNamedRanges] [-SkipTables] [-SkipWorksheetMetadata] [<CommonParameters>]
#
Parameter set: Document

Parameters

DifferenceDocument ExcelDocument requiredposition: namedpipeline: False
Workbook document to compare against.
Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook document.
MaxDifferences Int32 optionalposition: namedpipeline: False
Maximum number of differences to report.
SkipCells SwitchParameter optionalposition: namedpipeline: False
Skip visible cell value and formula comparison.
SkipCellStyles SwitchParameter optionalposition: namedpipeline: False
Skip style-index comparison for used cells.
SkipComments SwitchParameter optionalposition: namedpipeline: False
Skip legacy and threaded comment comparison.
SkipNamedRanges SwitchParameter optionalposition: namedpipeline: False
Skip workbook and sheet-scoped named-range comparison.
SkipTables SwitchParameter optionalposition: namedpipeline: False
Skip table metadata comparison.
SkipWorksheetMetadata SwitchParameter optionalposition: namedpipeline: False
Skip worksheet view, validation, and filter metadata comparison.

Outputs

System.Management.Automation.PSObject