简体   繁体   中英

Comparing two excel files

I'm in the process of developping a tool to compare two excel files.

One excel file contains around 300-400 rows. In each excel file there are 4 tables with different number of columns. tables are aligned one after the other in one sheet.

I tried using couple of excel comparison tool like Beyond Compare, TestComplete and ExcelCompare macro from source forge. But none did work. I think it's because the file contains different tables. So I planned to develop a tool to compare excel files.But according to my research it is not a simple task :)

My approach is to extract 2 rows from the 2 excel files (1st row from A.xlsx and first row from B.xlsx) at a time , put the values into sperate 2 arrays and then compare the values . Identify the different values and write it back to a new Excel file.

Is this approach efficient or suitable for a file with 300 rows...??? If anyone have a different and a simple idea please share with me.

I'm planning to use C# and Excel 2010 for the development.

Any help is appreciated :)

My approach would be to convert both sheets to CSV (by saving them to CSV format; Excel can do that for you) and then use string-distance algorithm to locate differences. Files Comparer and other content-comparison tools use this algorithm to give pretty good results.

This approach has the added benefit (compared to linear cell-by-cell comparison) that any missing rows will be identified neatly, instead of marking rest of the entire data as different.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM