To delay that time when I have to head out and double dig the vegetable
patch, I spent a few moments this morning digging around in the xlsx file
you attached and it looks as though the xml is not valid - at least from
POI's point of view.

This snippet of xml is copied from the file that you posted originally;

    <row r="1" spans="1:3">
      <c r="A1" t="str">
        <v>a</v>
      </c>

and as you can probably deduce, it marks the start of the first row in the
worksheet and indicates what cell A1 ought to contain. There are two
attributes for the row tag and the second indicates the cells type,
therefore it seems strange that POI tries to convert the cells contents into
an integer. Strange that is until you see how the cell ought - from Excel's
point of view - to be marked up;

    <row r="1" spans="1:3">
      <c r="A1" t="inlineStr">
        <is>
          <t>a</t>
        </is>
      </c>

That is the same piece of xml markup with the cell marked as an inline
string. Excel is quite happy to open this file - as it was the other version
I have to admit - and POI will successfully parse it.

So, it seemed logical to conclude that the xml Gnumeric outputs is not valid
as far as POI is concerned and I visited the Gnumeric website to see if it
would be possible - easilly - to alter the format of this output. As I
suspected, Gnumeric uses filters to convert files into different formats,
but I could not find one in the list
(http://projects.gnome.org/gnumeric/doc/sect-file-formats.shtml) that
supports saving files in Excel's OpenXML format. The complete list of
filters is;

Gnumeric
Applix
Comma Separated Values
Data Interchange Format
GNU Oleo
HTML
LaTeX
Linear and Integer Program
Lotus 1-2-3
Microsoft Excel
Multiplan SYLK
OpenOffice.Org / StarOffice
Plan Perfect
Postscript
PDF
Quattro Pro
SC/XSpread
Tab Separated Values
Text Formats
TROFF
Xbase
XHTML

Double clicking on the Microsoft Excel entry opened a page containing this
information (I have edited it and if you want to see the complete page
simply follow this link -
http://projects.gnome.org/gnumeric/doc/file-format-excel.shtml);

Limitations

    Most core features of the format are supported.

    Gnumeric does not support the very old file formats used by Excel™
versions prior to Excel™ 5.0.

    Gnumeric can open files from most of the Microsoft Excel™ file formats
and all of the recent file 
    formats. The formats supported are:

        * MS Excel™ 5.0/95.
        * MS Excel™ 97/2000/XP.
        * MS Excel™ 97/2000/XP & 5.0/95.

Plugin

    Supported by the 'MS Excel (tm)' plugin.

Format Details

    These are binary file formats.

Further Processing

    A number of other programs are able to process files in the Microsoft
Excel file format.


No mention is made of Excel's implementation on the OpenXML standard and so
I suspect that what is happening is that Gnumeric could - and that is could
- be saving the file using OpenOffices' xml based file format and then
appending the xlsx extension. From past experience with tools such as
AbiWord I have seen this sort of thing - AbiWord for example saves Word
documents as rtf files with a .doc extension. I need to test this hypothesis
out and will let you know what I discover; if this does prove to be the case
of course, you may need to look instead at something like the ODF Toolkit to
parse this file.

Yours

Mark B

PS If I am correct, one of the other interetsing 'discoveries' will be that
Excel can open OpenOffice spreadsheet files!



Bugzilla from [email protected] wrote:
> 
> https://issues.apache.org/bugzilla/show_bug.cgi?id=47889
> 
>            Summary: NumberFormatException when calling
>                     XSSFCell.getStringCellValue() on cell with a string
>            Product: POI
>            Version: 3.5-dev
>           Platform: PC
>         OS/Version: Linux
>             Status: NEW
>           Severity: normal
>           Priority: P2
>          Component: XSSF
>         AssignedTo: [email protected]
>         ReportedBy: [email protected]
> 
> 
> Created an attachment (id=24303)
>  --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24303)
> Problematic worksheet
> 
> When loading the example worksheet (see attached) using POI 3.5beta6, a
> call to
> getStringCellValue results in a number formal exception for cell A1 (first
> row,
> first column).  This cell contains the letter 'a' only.  While the
> worksheet is
> created with Gnumeric, it does load properly in Gnumeric and OpenOffice.
> 
> The following is the exception:
> 
> java.lang.NumberFormatException: For input string: "a"
>     at
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
>     at java.lang.Integer.parseInt(Integer.java:481)
>     at java.lang.Integer.parseInt(Integer.java:514)
>     at
> org.apache.poi.xssf.usermodel.XSSFCell.getRichStringCellValue(XSSFCell.java:257)
>     at
> org.apache.poi.xssf.usermodel.XSSFCell.getStringCellValue(XSSFCell.java:225)
> ...
> 
> The call on line 225 seems to suggest that the cell is identified as
> containing
> a string.
> 
> -- 
> Configure bugmail:
> https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are the assignee for the bug.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/DO-NOT-REPLY--Bug-47889--New%3A-NumberFormatException-when-calling-XSSFCell.getStringCellValue%28%29-on-cell-with-a-string-tp25570304p25623018.html
Sent from the POI - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to