-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Hi,
If the second file has more rows or columns than the first one, the tool does not report those differences. Because the for-loops are based on sheet1's dimensions:
private void processAllRows() throws Exception {
for (int rowIndex = 0; rowIndex <= sheet1.getLastRowNum(); rowIndex++) {
XSSFRow row1 = sheet1.getRow(rowIndex);
XSSFRow row2 = sheet2.getRow(rowIndex);
if (row1 == null || row2 == null) {
if (!(row1 == null && row2 == null)) {
crt.setDiffFlag(true);
processNullRow(sheet1, rowIndex, row2);
}
continue;
}
processAllColumns(row1, row2);
}
}
To solve this problem, since it's not complex, you can add two more variables int max_row and max_column, and use the max between both sheets.
int max_row = sheet11.getLastCellNum();
if (sheet12.getLastCellNum()>max_row) {
max_row = sheet12.getLastCellNum();
}
private void processAllRows() throws Exception {
for (int rowIndex = 0; rowIndex <= max_row); rowIndex++) {
XSSFRow row1 = sheet1.getRow(rowIndex);
XSSFRow row2 = sheet2.getRow(rowIndex);
if (row1 == null || row2 == null) {
if (!(row1 == null && row2 == null)) {
crt.setDiffFlag(true);
processNullRow(sheet1, rowIndex, row2);
}
continue;
}
processAllColumns(row1, row2);
}
}
Similar issue happens in function: processAllColumns(XSSFRow row1, XSSFRow row2)