Thanks Pierre! sheet 0 was hidden. I tried to access the required sheet by
its name rahter than number using getSheet and the program worked absolutely
fine :)

Cheers


Pierre Lavignotte wrote:
> 
> Guess what ?
> This spreadsheet has 3 worksheets, but 2 are hidden.
> So getSheetAt(0) doesn't return what you think.
> 
> ;)
> 
> Pierre
> 
> Cordialement,
> Pierre Lavignotte
> Ingénieur Conception & Développement
> http://pierre.lavignotte.googlepages.com
> 
> 
> On Thu, Jan 29, 2009 at 12:16 AM, rfconsultant <
> [email protected]> wrote:
> 
>>
>> Yes those 2 lines are the whole stacktrace.  I have looked into my
>> spreadsheet variable several times but it is not null however eclipse
>> debugger points the variable to be null, I dont for what reason. I have
>> copied and pasted the whole spreadsheet data into an other exccel file
>> and
>> the program works perfectly fine. It's very weired why is it happening?
>> If
>> you want I can send you the spreadsheet on  your email address. I really
>> want to get to the root of problem.
>>
>> Cheers
>>
>> [email protected]
>>
>>
>> Pierre Lavignotte wrote:
>> >
>> > I the 2 lines you wrote in your first email are the whole stacktrace,
>> then
>> > I
>> > think you access a null variable in your code and not in POI code.
>> >
>> >
>> > Cordialement,
>> > Pierre Lavignotte
>> > Ingénieur Conception & Développement
>> > http://pierre.lavignotte.googlepages.com
>> >
>> >
>> > On Wed, Jan 28, 2009 at 5:29 PM, Pierre Lavignotte <
>> > [email protected]> wrote:
>> >
>> >> I don't need the JAR but your stacktrace.
>> >>
>> >> Cordialement,
>> >> Pierre Lavignotte
>> >> Ingénieur Conception & Développement
>> >> http://pierre.lavignotte.googlepages.com
>> >>
>> >>
>> >> On Wed, Jan 28, 2009 at 5:26 PM, rfconsultant <
>> >> [email protected]> wrote:
>> >>
>> >>>
>> >>> I am using poi-3.2-FINAL-20081019.jar.
>> >>> I have tried to upload both the jar and excel sheet here again and
>> again
>> >>> but
>> >>> I dont know if the files hav been uploaded,  as I myself cant see the
>> >>> uploaded file. If you cant see the uploaded files give me your  email
>> >>> address and I 'll send those files to u through my personal email.
>> >>> Cheers
>> >>>
>> >>>
>> >>>
>> >>> Pierre Lavignotte wrote:
>> >>> >
>> >>> > Ok....
>> >>> > So please tell what version of POI you use and copy your stacktrace
>> >>> here.
>> >>> >
>> >>> > Pierre
>> >>> >
>> >>> > Cordialement,
>> >>> > Pierre Lavignotte
>> >>> > Ingénieur Conception & Développement
>> >>> > http://pierre.lavignotte.googlepages.com
>> >>> >
>> >>> >
>> >>> > On Wed, Jan 28, 2009 at 4:16 PM, rfconsultant
>> >>> > <[email protected]
>> >>> >> wrote:
>> >>> >
>> >>> >>
>> >>> >> Noooo! The contents of workbook0 row 3  cell 3 are not null but
>> >>> >> AWBE1NI-AWBE1NO and line 22 of java code is
>> >>> >> cell = row.getCell((short)3);
>> >>> >> .
>> >>> >>
>> >>> >>
>> >>> >>
>> >>> >> Pierre Lavignotte wrote:
>> >>> >> >
>> >>> >> > 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]
>> >>> >> >>
>> >>> >> >>
>> >>> >> >
>> >>> >> >
>> >>> >>
>> >>> >> --
>> >>> >> View this message in context:
>> >>> >>
>> >>>
>> http://www.nabble.com/problem-in-reading-simple-excel-sheet-tp21706313p21707719.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]
>> >>> >>
>> >>> >>
>> >>> >
>> >>> >
>> >>> http://www.nabble.com/file/p21709166/tkroute_oss-rc_090123_4pm.xls
>> >>> tkroute_oss-rc_090123_4pm.xls
>> >>> http://www.nabble.com/file/p21709166/poi-3.2-FINAL-20081019.jar
>> >>> poi-3.2-FINAL-20081019.jar<
>> http://www.nabble.com/file/p21709166/poi-3.2-FINAL-20081019.jarpoi-3.2-FINAL-20081019.jar
>> >
>> >>> http://www.nabble.com/file/p21709166/tkroute_oss-rc_090123_4pm.xls
>> >>> tkroute_oss-rc_090123_4pm.xls
>> >>> --
>> >>> View this message in context:
>> >>>
>> http://www.nabble.com/problem-in-reading-simple-excel-sheet-tp21706313p21709166.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]
>> >>>
>> >>>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/problem-in-reading-simple-excel-sheet-tp21706313p21717398.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]
>>
>>
> 
> 
:clap::clap::-):-):-)
-- 
View this message in context: 
http://www.nabble.com/problem-in-reading-simple-excel-sheet-tp21706313p21726502.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