Programming interview questions

Looking for good programming/interview questions?

Use the search below to find our solutions for selected questions!

Compare Excel sheets in Java

Sharing is caring!

What is this?

Dear Penthouse, I never thought it would happen to me, but I got my self in a situation where I had to compare two excel sheets and give a report. And because I am lazy in respect that I don't want to compare these sheets manually, I wrote myself a small tool that does this work for me.

This simple Java application basically loads 2 excel sheets of different structures containing names and vacation entries. Nobody but me will probably need this, but I though I'll share it anyway.

For example sheet A contains names and worked hours/per-day for a single month as follows:

...
...
... ... Name Surname ... 1 2 3 4 ... 31 ... ...
... ... Joe Doe ... 0 0 4 8 ... 0 ... ...
... ... Joe Doe ... 8 8 4 8 ... 8 ... ...
... ... Foo Bar ... 8 8 0 8 ... 8 ... ...
... ... ...
... ... Moe Goo ... 0 8 8 8 ... 8 ... ...
... ... ...

And sheet B contains names and vacation-flags for each day of the year as follows:

...
...
... ... Name, Surname ... 1 ... 31 1 ... 28 1 ... 31 ...
... ... Joe, Doe ...
... ... John, Appleseed ... V V
... ... Foo, Bar ...
... ... ...
... ... Moe, Goo ... V
... ... ...

If sheet A contains a total of 0 working hours for some day for a given person X, that person must have a V (vacation) entry in sheet B for that day of the year. See Moe Goo above.

If that is not the case for a person, we have an inconsistency between the two sheets.

This Java application finds and prints out the persons that are common in both sheets and have such inconsistencies. The application excludes weekends and holidays (loaded into the application as .xml) in its consistency check.

How to Import into Eclipse * File -> Import... -> Existing Maven Projects * Click Next * Click Browse... for the Root Directory * Select and open app * Click Finish * Do a mvn update on app

Full code

https://github.com/lucaslouca/compare-sheets