Performs test: 1. HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(); HSSFRow row = sheet.createRow((short) 0); row.createCell((short) 0); System.out.println("FIRST CELL NUM: " + row.getFirstCellNum() + "; " + " LAST CELL NUM: " + row.getLastCellNum()); Console results: EXPECTED: FIRST CELL NUM: 0; LAST CELL NUM: 1 OBSERVED: FIRST CELL NUM: 0; LAST CELL NUM: 0 Java-doc says: /** * gets the number of the last cell contained in this row <b>PLUS ONE</b>. * @return short representing the last logical cell in the row <b>PLUS ONE</ b>, or -1 if the row does not contain any cells. */ public short getLastCellNum() If we performs this test for sheet that read from file all is ok.
I think that this bug becomes only when we create and save new Excel file. When we read file that was saved by Excel evrything works good.(In reply to comment #0) > Performs test: > 1. > HSSFWorkbook workbook = new HSSFWorkbook(); > HSSFSheet sheet = workbook.createSheet(); > HSSFRow row = sheet.createRow((short) 0); > row.createCell((short) 0); > System.out.println("FIRST CELL NUM: " + row.getFirstCellNum() > + "; " + " LAST CELL NUM: " + row.getLastCellNum()); > Console results: > EXPECTED: FIRST CELL NUM: 0; LAST CELL NUM: 1 > OBSERVED: FIRST CELL NUM: 0; LAST CELL NUM: 0 > > Java-doc says: > /** > * gets the number of the last cell contained in this row <b>PLUS ONE</ b>. > * @return short representing the last logical cell in the row <b>PLUS ONE</ > b>, or -1 if the row does not contain any cells. > */ > > public short getLastCellNum() > > If we performs this test for sheet that read from file all is ok. (In reply to comment #0) > Performs test: > 1. > HSSFWorkbook workbook = new HSSFWorkbook(); > HSSFSheet sheet = workbook.createSheet(); > HSSFRow row = sheet.createRow((short) 0); > row.createCell((short) 0); > System.out.println("FIRST CELL NUM: " + row.getFirstCellNum() > + "; " + " LAST CELL NUM: " + row.getLastCellNum()); > Console results: > EXPECTED: FIRST CELL NUM: 0; LAST CELL NUM: 1 > OBSERVED: FIRST CELL NUM: 0; LAST CELL NUM: 0 > > Java-doc says: > /** > * gets the number of the last cell contained in this row <b>PLUS ONE</ b>. > * @return short representing the last logical cell in the row <b>PLUS ONE</ > b>, or -1 if the row does not contain any cells. > */ > > public short getLastCellNum() > > If we performs this test for sheet that read from file all is ok. I think that this bug becomes only when we create and save new Excel file by POI. When we read file that was saved by Excel evrything works good.
*** This bug has been marked as a duplicate of bug 43901 ***