I'm writing an application in c# that automates a comparison of values in two different databases.
The data is provided in two .xlsx files. These are loaded by the end user into the application. An in memory DataTable is then created from both files. One for each.
Now I need to compare column 1 from DataTable one with column 3 from DataTable two. The order of contents is not the same but they are all, always numeric values. Theres a couple of possible outcomes:
All cells match (but not in order). In other words, all cells that are in Column 1 from DataTable one are also in column 3 from DataTable two. There are no other cells present.
There is a cell present in column 1 from DataTable one which is not present in column 3 from DataTable two. In this case I want to write these cells to a seperate worksheet. I'm using closedXML and a workbook is already created and present.
There is a cell present in column 3 from DataTable two which is not present in column 1 from DataTable one. In this case I want to write these cells to a seperate worksheet. I'm using closedXML and a workbook is already created and present.
I have thought about creating a function that accepts two parameters. Both DataTables. A comparison would then be done on the first column of table one and the third column of table 3.
Another solution which I am working on now pasting both DataTables to a worksheet via ClosedXML. Extracting the relevant column (1 and 3) to another seperate worksheet and using a for each loop to compare all cells from both worksheets and get the differences. But I dont know how to go on about this as far as get the content which is not in column 1 but its in column 3 to worksheet A and the content which is in column 1 but not in column 3 to worksheet B.