if(hssf != null && hssf2 != null) {
// Check if the sheet count is same for both books
if(hssf.getNumberOfSheets() == hssf2.getNumberOfSheets()) {
// Iterate through the sheets
for(int i=0;i<hssf.getNumberOfSheets();i++) {
HSSFSheet sheet1 = hssf.getSheetAt(i);
HSSFSheet sheet2 = hssf2.getSheetAt(i);
// check if the sheet is not null
if(sheet1 != null && sheet2 != null) {
int rowCount1 = sheet1.getLastRowNum();
int rowCount2 = sheet2.getLastRowNum();
// check if rows are the same for both books
if(rowCount1 == rowCount2) {
// iterate through the rows
for(int j=sheet1.getFirstRowNum();j<=rowCount1;j++) {
HSSFRow row1 = sheet1.getRow(j);
HSSFRow row2 = sheet2.getRow(j);
// check if the rows are not null
if(row1 != null && row2 != null) {
Iterator it1 = row1.cellIterator();
Iterator it2 = row2.cellIterator();
while(it1.hasNext() && it2.hasNext()) {