0

I need to compare two Excel files to find any kind of content difference. Format/Color/Font differences are not to be considered. I followed the solution found at this post but it's based on the DBUnit XlsDataSet class. This class works on the assumption that the Excel file has a specific structure: the first row should represent the table header. This is not always true in my environment. Table header might start at cell C4, for instance.

However, I'd like to stick to DBUnit as it provides great support. Is anyone aware of how to configure where the table header starts in XlsDataSet class?

Thanks and regards

Community
  • 1
  • 1
MoZZoZoZZo
  • 233
  • 1
  • 10

1 Answers1

0

When the table header of one file starts at C4 and the other one at A1 they are already different.

In order to compare the data starting on different cells I can think of two methods.

  1. Before comparing, check for empty rows/columns, move the content to the first row/column.
  2. Include a "keyword" in your files that serves as a starting point.

Both ways are require a lot of work. Maybe it is easier to adapt your envionment so all files start at A1.

Lotzki
  • 489
  • 1
  • 4
  • 18
  • thanks for your reply. What I mean is that both files start at C4. I can accept that if they start at different cells they are different. But XlsDataSet seem unable to do so. Can that be somehow done? – MoZZoZoZZo Dec 07 '12 at 15:14
  • Im not familiar with the XlsDataSet but looking at the manual there is no way to start at another cell. Like i said, you need to convert the exel file into the proper format **before** using this method. My thought was to check for the first row and column that includes data. Then you have to overwrite the old table or create a new one, transfering the data to the first row. Look into [this](http://www.vogella.com/articles/JavaExcel/article.html) link, it explains how to read and write cells. From here I let you do the thinking :) If you are facing specific problems feel free to ask. – Lotzki Dec 07 '12 at 15:34