Click here to Skip to main content
15,894,249 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,


I am looking forward to compare two excel files and put the difference into another sheet. The main problem i encounter is that i do not know where i should start.

I have searched google/sw develeopers forums and i didn't find something i could use to compare 2 sheets.

I am trying currently to do this compare into a WinForm App and i'm stucked at this part. I do not even know how should i approach to this ..

Any suggestions ?? Code example ?? I would be grateful !

What I have tried:

Everything i have seen on internet but doesn't apply at all to my code.
Posted
Updated 22-Nov-16 22:35pm
v2

 
Share this answer
 
Comments
serbanov 23-Nov-16 2:55am    
Well, i have an excel with over 4k lines ... and i do not know if it's the right approach, but i will try.

Also, i have them written in my excel file as a tree view ... and i do not know how this will affect my compare... because i need to compare if version of files have changed or any of those files have been deleted... and that's why i'm afraid this might not work ...

https://s21.postimg.org/sqzwdaiif/excel_D.jpg ---> how my excel looks.
When you Google "excel compare sheets", you get only 15 million answers, and you found nothing useful ? Serious ?
Quote:
I am looking forward to compare two excel files and put the difference into another sheet.
First you need to define what you want to compare, cells values, formulas, formatting ...
Quote:
The main problem i encounter is that i do not know where i should start.
Are you kidding ? There is pretty much one way to do it.
You want to tell your user where are the differences.
For each cells of the 2 first sheets, you want tp write in third sheet if the cells are equal or not.
More or less, you will have:
VB
' not real code
Sheet3.A1=(Sheet1.A1=Sheet2.A1)

details vary on how you want to show differences and what differences you looking for.
Quote:
I have searched google/sw develeopers forums and i didn't find something i could use to compare 2 sheets.
Sometimes, you have to work to make ends meet.
When you found a solution in a language, your jobs is to translate in your language and adapt to your criteria.
Quote:
Everything i have seen on internet but doesn't apply at all to my code.
Programmer is not just a Copy/Paste job, sometimes you have to create things.
 
Share this answer
 
I'm doing something almost exactly like that (WPF application). I'm taking two spreadsheets, and merging them based on a user-specified mapping criteria (with one or more matching column pairs.

I'm using a Wizard-style form to guide the user through the process. My wizard pages are:

- Introduction
- Selecting a merge type (two files, or two worksheets in a single file)
- File (and worksheet) selection
- Column selection
- Matching criteria
- New (merged) file generation/preview/save
 
Share this answer
 
Comments
Philippe Mori 23-Nov-16 9:43am    
You don't really explain what to do or where to start....
You can read your Excel files via the Microsoft.Office.Interop.Excel namespace ()[^], which provides all the classes and methods necessary.
 
Share this answer
 
Comments
serbanov 23-Nov-16 3:26am    
I have to compare two Excel files and they are over 4k lines ... and they are written as a tree view. I don't know how much this would help me.
Richard MacCutchan 23-Nov-16 3:38am    
It does not matter whether you use the Interop or manu_dhobale's suggestion, the issue is exactly the same. Whatever form your data is held in you will have to read each item from both files to do the compare.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900