GemBox Support Forum

GemBox.Spreadsheet File Compare

Is there any specific functionality to help with comparing the text of 1 spreadsheet to another, or would this have to be specifically coded? Can the data in the spreadsheet be read while ignoring style elements? Thanks!


There is no straightforward API, but you could just iterate through cells in sheets that you’re comparing and check their value.

For example, something like this:

ExcelWorksheet sheet1 = ...
ExcelWorksheet sheet2 = ...

int rCount = Math.Max(sheet1.Rows.Count, sheet2.Rows.Count);
for (int r = 0; r < rCount; r++)
    ExcelRow row1 = sheet1.Rows[r];
    ExcelRow row2 = sheet2.Rows[r];

    int cCount = Math.Max(row1.AllocatedCells.Count, row2.AllocatedCells.Count);
    for (int c = 0; c < cCount; c++)
        ExcelCell cell1 = row1.Cells[c];
        ExcelCell cell2 = row2.Cells[c];

        if (cell1.Value != cell2.Value)
            Console.WriteLine($"{cell1.Name} cells have different values!");

Regarding the reading, note that there is a LoadStreamingMode.Read mode which loads a set of rows only when they are requested instead of loading the whole spreadsheet. See the Streamlined loading example.

I hope this helps.