Merge and Compare Excel Workbooks
Edit on GitHubConsolidate selected worksheets and produce explicit workbook or range differences for review and delivery gates.
Copy selected sheets into an existing target workbook, then compare the result with a baseline.
Consolidate selected sheets
Start with an existing target workbook, or create one with New-OfficeExcel.
Copy-OfficeExcelSheet -Path '.\Consolidated.xlsx' `
-Source '.\Regions.xlsx' `
-Sheet North,South `
-NamePrefix 'Region '
Use a stable prefix when sources can contain the same sheet names. Copy mode and name-validation options let the operation match the preservation and naming policy.
Compare a candidate
Compare-OfficeDocument -ReferencePath .\Before.xlsx -DifferencePath .\After.xlsx checks cells, styles, named ranges, tables, worksheet metadata, and comments. The common report exposes AreEqual, Differences, and NativeReport. Pass New-OfficeExcelCompareOptions through -Options to choose the comparison scope. Skip categories only when the delivery contract says they do not matter. Compare-OfficeExcelRange narrows the comparison to a known business area.
The merge-workbooks recipe consolidates two regional sheets. The compare-workbooks recipe creates a controlled cell difference and reports it.
After a merge, run the checks described in validation and repair.