I cannot think what to say about this because I wrote the following bit of test 
code;

        File infile = null;
        HSSFWorkbook workbook = null;
        HSSFSheet sheet = null;
        HSSFRow row = null;
        HSSFCell cell = null;
        
        
        try {
            infile = new File("C:\\temp\\book1.xls");
            workbook = new HSSFWorkbook(new java.io.FileInputStream(infile));
            sheet = workbook.getSheetAt((short)0);
            row = sheet.getRow(1);
            cell = row.getCell(0);
            System.out.println(cell.toString());
            
            cell = row.getCell(1);
            System.out.println(cell.toString());
        }
        catch(java.io.IOException ioEx) {
            System.out.println(ioEx.getMessage());
        }

and did not encounter the problem that you saw.

Why not try running 'my' code against your workbook to see what the result is? 
If you still see that a null value is returned then have a close look at the 
worksheet to make sure that all is as you expect. Finally, if you still 
encounter problems, try to recreate it with a small test workbook - if your 
original one is not small - and attach that to a message so that one of us can 
take a closer look.

--- On Mon, 9/15/08, Ruchi Agrawal <[EMAIL PROTECTED]> wrote:
From: Ruchi Agrawal <[EMAIL PROTECTED]>
Subject: Not null cell returns null
To: "POI Users List" <[email protected]>
Date: Monday, September 15, 2008, 9:53 AM

have to send this again due to some format probs earlier.

I have a sheet where the data looks something like .col1 and col2 are headers 
col1 col2 
xyz (265.3457) 
 
When using the below code i can not get the row to return me the correct value
for  cell "xyz". row.getCell(0) below always returns a null even tho
this cell 0 on row 1 has the value "xyz". Even the
row.cellIterator(); returns only one cell i.e the -265.3457 and does not return
"xyz" . Can someone please suggest what is it that i am doing wrong.
 
HSSFRow row = sheet.getRow(1);
System.out.println(row.getCell(0));
System.out.println(row.getCell(0));
java.util.Iterator<HSSFCell> it = row.cellIterator();
 
output from above
null
-265.3457
 
Thanks


      


      

Reply via email to