Hi,

Not sure where you line 22 is, but maybe your sheet 0 or row 3 is null.
You should test it before use.

Pierre

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


On Wed, Jan 28, 2009 at 3:03 PM, rfconsultant <[email protected]
> wrote:

>
> I have written a simple code to read certain cell value in excel sheet. The
> program works absoulutely fine with some workbooks but some workbooks r
> givin
> Exception in thread "main" java.lang.NullPointerException
>
> at Excel_test.main(Excel_test.java:22)
>
> . I dont know whats worong as the data format and location of the excel is
> unchanged.(Note: The files with error have macro in that but my program has
> nothing to do with macro I am only concerned with the content) java code
> for
> your info is given below
>
>
>
> import org.apache.poi.hssf.usermodel.*;
>
> import java.io.*;
>
> public class Excel_test {
>
>        /**
>         * @param args
>         */
>        public static void main(String[] args) {
>                // TODO Auto-generated method stub
>                HSSFRow row;
>            HSSFCell cell;
>            String s2;
>                try{
>
>                        InputStream myxls= new
>
> FileInputStream("C:\\Ericsson\\E4E\\workspace\\Route_updater\\tkroute_oss-rc_090123_4pm.xls");
>                        HSSFWorkbook wb = new HSSFWorkbook(myxls);
>                        HSSFSheet sheet = wb.getSheetAt(0);
>
>                        row = sheet.getRow(3);
>                                        cell = row.getCell((short)3);
>                                        if (cell!=null){
>
>                                        s2=cell.getStringCellValue();
>                                        System.out.println(s2);
>                }
>                }
>
>                catch(FileNotFoundException ex)
>                {
>                        System.out.println("FileNotFoundException : " + ex);
>                }
>                catch(IOException ioe)
>                {
>                        System.out.println("IOException : " + ioe);
>                }
>
>
>
> }
> }
>
>
>
> --
> View this message in context:
> http://www.nabble.com/problem-in-reading-simple-excel-sheet-tp21706313p21706313.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]
>
>

Reply via email to