You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Sanjiv Jivan <sa...@gmail.com> on 2005/08/26 20:24:41 UTC
HSSFCell.getStringCellValue too strict
Hi,
HSSFCell.getStringCellValue() thows various NumberFormatException's if the
data type in Excel is not of String type. I think this is too strict.
Throwing an exception when getting a number from String field makes sense
but I would much prefer if HSSFCell.getStringCellValue returned to
toString() value of whatever the cell value.
Thanks,
Sanjiv
Re: HSSFCell.getStringCellValue too strict
Posted by Sanjiv Jivan <sa...@gmail.com>.
Thanks for your response. I've looked at the relevant code and see that the
class HSSFCell stores the variant and various types and not all members will
be populated depending of the underlying cell data type. I would say that it
is an implementation detail that the single class HSSFCell has members like
private double cellValue <javascript:searchRef('cellValue')>;
private String <javascript:searchRef('String')>
stringValue<javascript:searchRef('stringValue')>
;
private boolean booleanValue <javascript:searchRef('booleanValue')>;
private byte errorValue <javascript:searchRef('errorValue')>;
where depending on the cell type, one of the above members would have a
value. I would have preferred if HSSFCell was a abstract class with data
type specific subclasses depending on the excel cell type. Ex : DoubleCell,
StringCell, BooleanCell etc. Each of these classes can have a toString()
implementation. (analogous to the Double, Integer, Float etc classes) I
think this approach is more object oriented compared to the current
implementation. The Worksheet API can return cells of the abstract type
HSSFCell.
Regards,
Sanjiv
On 8/29/05, KHZ (SAW) <ka...@sawag.com> wrote:
>
> Hi Sanjiv.
>
> It can't work. It's a variant and the type determines which field has to
> be read. So when there's a numeric value inside the content of the
> string field may be arbitrary.
>
> With formulas there are less exceptions. There you just receive an empty
> value if you query with the wrong type.
>
> Regards, Karl-Heinz.
>
>
> -----Ursprüngliche Nachricht-----
> Von: Sanjiv Jivan [mailto:sanjiv.jivan@gmail.com]
> Gesendet: Freitag, 26. August 2005 20:25
> An: POI Users List
> Betreff: HSSFCell.getStringCellValue too strict
>
> Hi,
> HSSFCell.getStringCellValue() thows various NumberFormatException's if
> the
> data type in Excel is not of String type. I think this is too strict.
> Throwing an exception when getting a number from String field makes
> sense
> but I would much prefer if HSSFCell.getStringCellValue returned to
> toString() value of whatever the cell value.
>
> Thanks,
> Sanjiv
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
>
>
AW: HSSFCell.getStringCellValue too strict
Posted by "KHZ (SAW)" <ka...@sawag.com>.
Hi Sanjiv.
It can't work. It's a variant and the type determines which field has to
be read. So when there's a numeric value inside the content of the
string field may be arbitrary.
With formulas there are less exceptions. There you just receive an empty
value if you query with the wrong type.
Regards, Karl-Heinz.
-----Ursprüngliche Nachricht-----
Von: Sanjiv Jivan [mailto:sanjiv.jivan@gmail.com]
Gesendet: Freitag, 26. August 2005 20:25
An: POI Users List
Betreff: HSSFCell.getStringCellValue too strict
Hi,
HSSFCell.getStringCellValue() thows various NumberFormatException's if
the
data type in Excel is not of String type. I think this is too strict.
Throwing an exception when getting a number from String field makes
sense
but I would much prefer if HSSFCell.getStringCellValue returned to
toString() value of whatever the cell value.
Thanks,
Sanjiv
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/