Apache poi get the used row number
I have usedint totalRows = ExcelWSheet.getPhysicalNumberOfRows() to get the used number of rows in a XSSFWorksheet, but it is not returning the actual result.
Is there any way to get the current row number or used number of rows?
I have already tried
ExcelWSheet.getLastRowNum(), but it returned a big number. Please help me to solve this issue?
I appreciate your help.
Yes that happens with Excel. Reason of that is that earlier there were some data in the excel rows but not you have cleared the cell but those cells are actually initialised. I can explain this how it works but you wil get confuse on this. Work arounds for this are:
1) Create a new sheet and make sure you just use first few rows.
2) Select the number of rows in the excel and delete those rows even if they are blank and does not contain any data. Make sure that you just not delete the cell rather delete the complete rows. Th number of rows to be deleted = the number you get in your result when you use the ExcelWSheet.getLastRowNum().