Morning Anrdew,
Can we see some of the sort of code you are using please because I am not at
all certain I understand what you are asking here?
To deal with your second question firstly, if you are adding rows to the end
of an existing worksheet, the idiom I would adopt (as if that is any
recommendation!) is this;
...
row = worksheet.getRow(10);
if(row == null) {
row = worksheet.createRow(10);
}
.....
that way should deal with the situation where you try to retrieve a row that
did not exist in the original file so you lazilly create it and add it to
the worksheet; and of course I am assuming that the worksheet file exists
and that you have already opened it and retrieved a worksheet from it.
The reason, I suspect, ou have encountered this problem is that the Excel
file will only contain records for rows that have been populated. Therefore,
if you try to recover row seven for example even if rows six and eight have
been defined it may not exist if the cells on that row are empty. The way I
like to think about it all is MVC, the model view controller pattern. The
Excel file is the model and Excel itself is both the view and the
controller; the view does not need the file to contain records for every
cell on every row, it is able to create the display independant of the model
and simply calls upon that element for the data it needs and the formatting
information it requires.
Yours
Mark B
Andrew Feller-2 wrote:
>
> Hello,
>
>
>
> I am using POI 3.0.1 to dynamically populate an Excel spreadsheet, however
> I continually encounter NullPointerException whenever I try to retrieve or
> create rows at the end of the document. Apparently, it doesn’t see any
> more rows “defined” and thus returns NPE.
>
>
>
> QUESTION: Is it possible to tell POI to continually retrieve / create rows
> regardless of being touched (formatting, borders, etc)?
>
>
>
> Thank you,
>
>
>
> Andrew R. Feller
> Software Engineer
> TraceSecurity, Inc.
> 5615 Corporate Blvd Ste 200A
> Baton Rouge, LA 70808
> Phone: (225) 612-2121 X 31004
> Fax: (225) 612-2115
>
>
>
>
--
View this message in context:
http://old.nabble.com/NPE-while-retrieving---creating-rows-within-spreadsheet-tp26784101p26790762.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]