poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Davis, Zach" <Zach_Da...@polk.com>
Subject Issues with Sheet.getLastRowNum() and getPhysicalNumberOfRows() being incorrect.
Date Mon, 22 Dec 2008 14:41:33 GMT
I have an Excel document with 18 rows. 18th row being the row with 18
displayed in Excel. I would expect Sheet.getLastRowNum() to return 17
like it does for my other 16,000 files. For some reason I'm getting 19.

So this isnt the actual code but rather a simplification that details my

....  (omitted sheet getting loaded from disk)

int firstRowNum = sheet.getFirstRowNum();
int lastRowNum = sheet.getLastRowNum();

System.out.println("Last row: " + sheet.getLastRowNum());
System.out.println("Phys row: " + sheet.getPhysicalNumberOfRows());

for (int i = firstRowNum; i <= lastRowNum; i++) {
	row = sheet.getRow(i);
	if (row == null) {
	    System.err.println("ReadCells(): Row " + i + " was null!");
	...... (more code)


Last row: 19
Phys row: 19
ReadCells(): Row 18 was null!

Now I would expect the valid number of rows to be from 0-17 and using
excel my last row does appear to be at 18 in the UI. I'm using poi 3.1
FINAL and I've already checked the changelogs to see if this bug was
fixed in newer versions. Since this is part of a large project I am
unable to upgrade poi but using the latest version my test code still

I'm interested in any workarounds or suggestions. Due to these files
containing personal information I am not authorized to provide them
unfortunately :(.

Zach Davis
Associate IT Programmer Analyst
R.L. Polk Southfield Office

This message has originated from R. L. Polk & Co.,
26955 Northwestern Highway, Southfield, MI 48033.
R. L. Polk & Co. sends various types of email
communications.  If this email message concerns the
potential licensing of a Polk product or service, and
you do not wish to receive further emails regarding Polk
products, forward this email to Do_Not_Send@polk.com
with the word "remove" in the subject line.

The email and any files transmitted with it are confidential
and intended solely for the individual or entity to whom they
are addressed.

If you have received this email in error, please delete this
message and notify the Polk System Administrator at

  • Unnamed multipart/alternative (inline, 7-Bit, 0 bytes)
View raw message