So when you have two similar Excel workbooks or two versions of the same spreadsheet, what is the best thing to do first? That’s right, compare these files for differences, and then perhaps merge them into one file. Also, comparing workbooks will help you detect possible problems, such as incorrect tables, extra entries, inconsistent formulas, or improper formatting.GroupDocs.Comparison gives you many options for comparing a wide range of supported file formats, including Excel formats.
After the comparison, there are three colors on the resulting file that highlight the differences. You can also specify the colors yourself to identify the next difference:
Elements that were inserted in the first file. – blue, by default
Elements wich were deleted from the first file – red, by default
Elements that have changed their styles (font, color, etc.) – green, by default
The code sample to compare two Excel files:
stringsourcePath=@"source.xlsx";// NOTE: Path to the source Excel documentstringtargetPath=@"target.xlsx";// NOTE: Path to the target Excel documentstringresultPath=@"result.xlsx";// NOTE: Path to the result Excel documentusing(Comparercomparer=newComparer(sourcePath)){comparer.Add(targetPath);CompareOptionscompareOptions=newCompareOptions{DetectStyleChanges=true,DetalisationLevel=DetalisationLevel.High};comparer.Compare(resultPath,compareOptions);}
Source / Target / Result Excel files
Source
Target
Result
As a result, you have an Excel file with highlighted changes, in which the deleted elements are marked with a font red, the added – in blue, and the modified – in green.
More resources
Advanced Usage Topics
To learn more about document comparison features, please refer to the advanced usage section.
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full-featured .NET library we provide simple, but powerful free Apps. You are welcome to compare your DOC or DOCX, XLS or XLSX, PPT or PPTX, PDF, EML, EMLX, MSG and other documents with free to use online GroupDocs Comparison App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.