Get number of rows with Apache POI

504 views Asked by At

I try to count number of rows in a xls file with Apache POI. File contains 300 rows, but I get just 24 as output of both of these commands.

int noOfColumns = sh.getRow(0).getPhysicalNumberOfCells();
int noOfColumns = sh.getRow(0).getLastCellNum();

There aren't any empty rows between lines in file.

1

There are 1 answers

0
plaidshirt On BEST ANSWER

It gives right number of rows on a sheet:

int rnum = sheet.getLastRowNum() - sheet.getFirstRowNum();