Hi,

the only thing I think about is that you may have one or two blank rows (=no
record) before the 18th, and one or two rows after the 18th with empty data
so they doen't display in Excel.
Hope I'm clear...

Try :
for (int i = firstRowNum; i <= lastRowNum; i++) {
       row = sheet.getRow(i);
       System.out.println("Row " + i);
}

Maybe you'll find there is a missing number in the 0-17 range, and a row at
index 19.

Good luck,
Pierre

Cordialement,
Pierre Lavignotte
Ingénieur Conception & Développement
http://pierre.lavignotte.googlepages.com


On Mon, Dec 22, 2008 at 3:41 PM, Davis, Zach <[email protected]> wrote:

> 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
> problem.
>
>
> ....  (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!");
>            System.exit(2);
>        }
>        ...... (more code)
> }
>
> Produces:
>
> 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
> bombs.
>
> I'm interested in any workarounds or suggestions. Due to these files
> containing personal information I am not authorized to provide them
> unfortunately :(.
>
> Cheers,
> 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 [email protected]
> 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
> [email protected].
> *****************************************************************
>

Reply via email to