0

I'm a beginner in Java and I have a problem.

I have two excels that I need to compare and extract the changes. Excels are practically the same but differ in row order (example below). How to extract information about the change in the red field relative to the previous excel?

Example

Apache Poi compares row by row so it fails. I was thinking about using java stream but I have no experience with it. Is it better to pull into tables? I'm not asking for ready code, but for tips.

Thanks for the help

2 Answers2

0

I think what you need is to do the following:

  1. Upload each excel to the memory.
  2. Tranform each excel row to a Pojo.
  3. Add all rows to list (you will have two lists).
  4. Sort each list separately.
  5. Create a new list with the differences.
  6. Tranform the new list back to exel.
user2304483
  • 1,462
  • 6
  • 28
  • 50
0

Easiest way to compare two Excel files in Java?

Other way:

You can use set here.

Store excel data of each sheet in 2 different Set, namely SetA and SetB.

Do

(Set A- Set B) + (Set B - Set A)

to filter out difference between 2 sets, hence fetching difference between 2 sheets data.