vb.netcomparefile-comparison

Adding the data present in only file1 while comparing


Consider I have two excel file, compare and merging two file and genarating new report, While doing in programatically -

Few data present in file 1 and that data not present in file2 so How to add the data present in only file1?

If (merge(i).Filename = merge1(j).Filename1) Than

 'print present data

Else

 'print not present data

i want know the correct logic for this.. Help me.


Solution

  • A few things to note..

    Two Excel documents (A) and (B)

    A (Master) | B (Slave)

    Copy everything extra from (B) to (A)... But if (A) has data, ignore (B) data

    A (Master) | B (Master)

    Copy everything in (B) to (A) where (A) has no data, Append. However, skip anything in (B) when (A) has data, irrespective of it's different

    A (Slave) | B (Slave)

    Copy everything from (A) and (B) and append new excel file with Both datasets if have data and create new Master (C)

    Ideally you need to decide your process of how you want the program to react in every scenario. Plan each path that could possibly happen with the merge. You'll need to itterate through every cell and update each one depending on what cells to merge and the condition from above (or your own conditioning).

    It's not a straight forward answer nor a straight forward question. Have a look here about programatic access to Excel through VB.NET. This page should get you started on itteration of the workbooks.