You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "Tomasek, Kevin" <kt...@intersil.com> on 2011/07/18 21:13:16 UTC

XLS file, getNumericCellValue failing due to null value

I have an instance of where the call getNumericCellValue is failing
because it thinks that the cell value is null.  I can see in the
debugger (eclipse) that the cell type is indeed 0 (zero), which means
numeric, and the cell in question is not null, the record value is not
null, but the program consistently fails at the same place.

 

The spreadsheet is an .xls file that 4 rows x 10 columns.  The program
itself is 80 +/- lines long.  The getStringCellValue works perfectly
fine on the remainder of the spreadsheet.  

 

I have used the POI API on another project and it worked fine.  The
spreadsheet was 100X more complicated and 100x bigger.

 

I have exited eclipse, saved the spreadsheet to a different name,
started a new spreadsheet.  No difference.

I have exported the program, it fails too.

 

I am at a loss as to what to do next.  Suggestions?

 

I have some screen shots of both the debugger and spreadsheet if that
would help.  This is the first time to post so I don't know the standard
policy is on this.

 

Thanks  Kevin

 


Re: XLS file, getNumericCellValue failing due to null value

Posted by Nick Burch <ni...@alfresco.com>.
On Mon, 18 Jul 2011, Tomasek, Kevin wrote:
> I have an instance of where the call getNumericCellValue is failing 
> because it thinks that the cell value is null.  I can see in the 
> debugger (eclipse) that the cell type is indeed 0 (zero), which means 
> numeric, and the cell in question is not null, the record value is not 
> null, but the program consistently fails at the same place.
>
> The spreadsheet is an .xls file that 4 rows x 10 columns.  The program
> itself is 80 +/- lines long.  The getStringCellValue works perfectly
> fine on the remainder of the spreadsheet.

Can you try running BiffViewer[1] against the file, and see what that 
shows for the problem cell? You'll need to find the section of records for 
the sheet in question (easy if you only have one sheet!), then look for 
the record for your porblem cell.

For example, this is the output for cell B2 which is a string:

Offset=0x0000310F(12559) recno=322 sid=0x00FD size=0x000A(10)
[LABELSST]
     .row    = 0x0001
     .col    = 0x0001
     .xfindex= 0x000F
   .sstIndex = 0x000F
[/LABELSST]

What does your file show up as?

The second check is to see what the Microsoft Binary File Format 
Validator[2] thinks of your file? Does it consider your Excel file to be 
valid, or does it identify a fault with the file itself?

Nick

[1] org.apache.poi.hssf.dev.BiffViewer
[2] http://blogs.msdn.com/b/officeinteroperability/archive/2011/07/12/microsoft-office-binary-file-format-validator-is-now-available.aspx

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