I'm trying to find the index of the last row in an excel spreadsheet using Apache's POI for Java.
I thought this should be possible with getLastRowNum()
or getPhysicalNumberOfRows()
but they don't seem to give the right results. For example, I have a one line spreadsheet and these two functions return a value of 1140. Another two line spreadsheets gets a value of 1162.
The other problem is that I cannot just look for the first empty row, since it may be possible to have empty rows between rows of valid data.
So is there a way to find the index of the last row? I suppose I could make it a requirement to not have empty rows between data, but I was hoping for a better solution.
Edit: For the record using an iterator didn't help. It just iterated over the 1140/1162 supposed rows.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…