Morning Mark,

Thank you for your reply.

My code was strictly using the getRow() method though I was aware of 
createRow().  As an experiment, I switched all getRow() to createRow() and the 
problem persisted; I thought perhaps createRow() was intelligent enough to 
attempt to retrieve the row via getRow() first and only create it if necessary. 
 I must admit I was quite confused when the Javadocs continually explained it 
only retrieves "defined" rows with no mention of how to define a row.  I 
include a sample at the bottom.

I will see about making the changes you suggested and give it a whirl.  I 
appreciate your help.  It would be nice if either A) getRow() had an 
alternative signature getRow(Boolean create) or B) createRow() would implicitly 
check for existing rows before creating new ones.

Regards,
Andrew

SAMPLE CODE

InputStream xls = new FileInputStream(SPREADSHEET_SOURCE);
HSSFWorkbook wb = new HSSFWorkbook(xls);
HSSFSheet sheet = wb.getSheetAt(0);

int rowNumber = 2;

List<People> people = PeopleUtils.fullList();

for (People person : people) {
        HSSFRow row = sheet.getRow(rowNumber);
        FillNameDetails(wb, people, row);
        FillAddressDetails(wb, people, row);
        rowNumber++;
}


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


-----Original Message-----
From: MSB [mailto:[email protected]] 
Sent: Tuesday, December 15, 2009 1:56 AM
To: [email protected]
Subject: Re: NPE while retrieving / creating rows within spreadsheet


....and I should have said that you can do something similar with cells, try
to get the cell from the row, check what the call returns and if it is null
lazilly create the cell. Just to be a PTBO (a Professor of The B&**%in
Obvious (Copyright Bob Crowe 1996)) if that solves your problems, there is
no need to post your code here.

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-tp26784101p26790989.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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to