You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by David Teruel <da...@tid.es> on 2004/06/14 13:44:54 UTC

NullPointerException

Hello.

I'm having an error with the following code, and I don't know why. (p_wb
is a HSSFWorkbook pased as argument in a procedure, and its a excel
workbook which is used as a template)


        HSSFSheet s =null;
        HSSFRow r=null;
        HSSFCell c1=null;
        i = 0;
         s= p_wb.getSheetAt(0);
         r= s.getRow(1+(i*2));
         c1= r.createCell((short)5);

I get a NullPointerException, because s.getRow() returns null, but the
row already exists.
Does anyone has an idea?.

Thanks.


--
**************************************************
             David Teruel Vioque
        GFI-Informática. Telefónica I+D
        Tfl: 91.312.99.85 (29985)
        email: davidt62@tid.es
               dteruel@gfi-info.com
**************************************************
Ojalá se te acabe la mirada constante, la palabra
precisa la sonrisa perfecta ... Silvio Rodríguez.
**************************************************



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


AW: NullPointerException

Posted by "KHZ (SAW)" <ka...@sawag.com>.
Hi David.

If you have e.g. 20 rows then don't assume that e.g. row number 10
exists.

For every row (and even for every cell) check whether it's null.

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: David Teruel [mailto:davidt62@tid.es] 
Gesendet: Montag, 14. Juni 2004 13:45
An: POI Users List
Betreff: NullPointerException

Hello.

I'm having an error with the following code, and I don't know why. (p_wb
is a HSSFWorkbook pased as argument in a procedure, and its a excel
workbook which is used as a template)


        HSSFSheet s =null;
        HSSFRow r=null;
        HSSFCell c1=null;
        i = 0;
         s= p_wb.getSheetAt(0);
         r= s.getRow(1+(i*2));
         c1= r.createCell((short)5);

I get a NullPointerException, because s.getRow() returns null, but the
row already exists.
Does anyone has an idea?.

Thanks.


--
**************************************************
             David Teruel Vioque
        GFI-Informática. Telefónica I+D
        Tfl: 91.312.99.85 (29985)
        email: davidt62@tid.es
               dteruel@gfi-info.com
**************************************************
Ojalá se te acabe la mirada constante, la palabra
precisa la sonrisa perfecta ... Silvio Rodríguez.
**************************************************



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org