How to get row count in an Excel file using POI library?
apache-poi, excel, java, poi-hssf
Solution
Try Sheet.getPhysicalNumberOfRows()
Problem
Guys I'm currently using the POI 3.9 library to work with excel files. I know of the `getLastRowNum()` function, which returns a number of rows in an Excel file. The only problem is `getLastRowNum()` returns a number with the count starting from 0. So if an Excel file uses the first 3 rows, `getLastRowNum()` returns 2. If an Excel file has just 1 row, `getLastRowNum()` returns 0. The problem occurs when the Excel file is completely empty. `getLastRowNum()` still returns 0, so I cannot determine if the Excel file has 1 row of data, or if its empty. So how can I detect if an Excel file is empty or not ?