Can you please add the following change to the changelog: Somewhere between 2.5.1-FINAL and 3.0-FINAL in org.apache.poi.hssf.usermodel.HSSFRow the method getLastCellNum changed from "get the number of the last cell contained in this row." to "Gets the index of the last cell contained in this row PLUS ONE." This is IMHO one of the most important changes between 2.5.1 and 3.x because it breaks existing functionality (and it took me lots of time to find this unmentioned change during upgrading as 3.2 produces only an NPE when accessing nonexistent cells...) Thank you very much!
It's so long since POI 2.5.x that I can't remember for sure... However I seem to recall that there was a bug and some files returned the last cell index plus one, and some the last index. This was fixed to always be plus one. Someone else might be able to confirm or deny this though? Otherwise, you may find the iterators (introduced in 3.5) much easier to work with, see http://poi.apache.org/spreadsheet/quick-guide.html#Iterator
if you compare the javadocs of getLastCellNum() of http://archive.apache.org/dist/jakarta/poi/release/bin/poi-bin-2.5.1-final-20040804.zip and http://archive.apache.org/dist/jakarta/poi/release/bin/poi-bin-3.0-FINAL-20070503.zip at this position: poi-bin-2.5.1-final-20040804.zip/docs/apidocs/org/apache/poi/hssf/usermodel/HSSFRow.html with poi-bin-3.2-FINAL-20081019.zip/poi-3.2-FINAL/docs/apidocs/org/apache/poi/hssf/usermodel/HSSFRow.html you can see there was a change. Thanks for the iterator hint, I'll take a look at it.
The "plus one" change was made intentionally, the main goal was to make lastCellNum the standard upper bound when iterating over cells: int minColIx = row.getFirstCellNum(); int maxColIx = row.getLastCellNum(); for(int colIx = minColIx; colIx < maxColIx; colIx++) { Cell cell = row.getCell(colIx); //... do something with cell } It might had broke the code written for POI 2.5.1, but on the other hand it prevented incorrect usages of lastCellNum in 'for' loops which seemed more important at that time. Yegor (In reply to comment #2) > if you compare the javadocs of getLastCellNum() of > http://archive.apache.org/dist/jakarta/poi/release/bin/poi-bin-2.5.1-final-20040804.zip > and > http://archive.apache.org/dist/jakarta/poi/release/bin/poi-bin-3.0-FINAL-20070503.zip > > at this position: > > poi-bin-2.5.1-final-20040804.zip/docs/apidocs/org/apache/poi/hssf/usermodel/HSSFRow.html > with > poi-bin-3.2-FINAL-20081019.zip/poi-3.2-FINAL/docs/apidocs/org/apache/poi/hssf/usermodel/HSSFRow.html > > you can see there was a change. > > > Thanks for the iterator hint, I'll take a look at it.