When i get last row of sheet, getLastRowNum return last row formated instead last row has data. Have another way to get last row have data? Thank you very much for reading and support.
Created attachment 34459 [details] excel formated last row excel file added formated last row (1048576) as currency (decimal: 0; symbol: $) test code: @Test public void testGetLastRowNum() throws IOException { String filePath = "test-data/60389_get_last_row_num.xlsx"; try (XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(filePath))) { XSSFSheet sheet = wb.getSheetAt(0); System.out.println(sheet.getLastRowNum()); } }
getLastRowNum returns the row number of the last physical row in the sheet. This is equivalent to Ctrl+Down in Excel The Sheet interface doesn't have a function to get the last row containing at least one non-blank cell. You will need to iterate over the rows (ideally a reverse iterator) and iterate over cells in each row to determine if that row is blank, then return the row number of the last non-blank row. This sounds like it could be expensive. You may want to look at http://stackoverflow.com/questions/38204944/apache-poi-check-if-a-column-is-empty/38238218#38238218 for ideas on efficient iteration. Since this is not a bug but a usage question, I. If you have more questions, please ask them on user@poi.apache.org mailing list. https://poi.apache.org/mailinglists.html
Thank you very much, Javen O'Neal