We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Need to Compare cells of two sheets and create a third sheet with value java


I have a excel file with two sheets “A” and “B”

Need to compare corresponding cells in two sheets and create a third sheet with result.

Attaching excel.

Please help.FinalReport.zip (10.1 KB)


Thanks for the sample file.

Well, for comparing cells, there is no better way to cope with such kind of requirements. I am afraid, you have to iterate the cells in two sheets and compare elements in the enumeration one by one.

Please note, you have to use your own code to compare it row by row. When comparing one row, compare the cells column wise. However, you should not use the code something like the structure:

for(int row…){for(int col…){cells[row,col]…}}

You should use methods like Cells/Row.GetEmumerator() in the enumerator, we provide cells row by row, for cells in one row, the cells are provided column by column. See the sample code segment on how to get first worksheet’s cells (cell by cell) in enumeration just for hints:
Sample code:

IEnumerator cellEnumerator = worksheet1.Cells.Rows[0].GetEnumerator();
Cell currentCell = null;
//int colNext = 1;

// Traverse cells in the collection
while (cellEnumerator.MoveNext()) 
currentCell = cellEnumerator.Current as Aspose.Cells.Cell;


Hope, this helps a bit.