Excel

Comparing Data

CompareToFile compares the targeted range against data in another file. CompareToGrid compares against an in-memory grid. CompareToRange compares against another range in the same workbook. Configure the search field with WithSearchValue when comparing by a specific column. GetCompareResults retrieves the comparison output as an IGPALGrid<string> - the grid contains rows identifying differences between the two sources.

Examples

GPAL Fluent: High-level fluent C# API

//GetCompareResults must be called after CompareToFile, CompareToGrid, or CompareToRange. The resulting grid contains one row per difference found between the two data sets.

// Compare two sheets and get differences

var differences = GPAL.Grid.ToGPALObject();

GPAL.Excel

.WithFile("report.xlsx")

.WithSheet("Actual")

.WithRange("A1:D100")

.CompareToRange("Expected!A1:D100")

.GetCompareResults(out differences);


// Compare against a reference file

GPAL.Excel

.WithFile("current.xlsx")

.WithSheet("Sheet1")

.WithRange("A1:E500")

.CompareToFile("baseline.xlsx")

.GetCompareResults(out differences);

💬 Ask GPAL