You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Davinder Kohli <kd...@yahoo.com> on 2004/07/16 22:35:47 UTC

formula return type

Hi,
How do I determine the return type of a formula? Is
there an API provided to do this or do I need to
checkout the formula and then determine its return
type.

Thanks,
Davinder


		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

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


Re: AW: AW: formula return type

Posted by Avik Sengupta <av...@itellix.com>.
Looking at the code, I think there are some bugs in getBooleanValue in
HSSFCell. It doesn't handle formulas. Also, with getStringValue, i'm not
sure you can differentiate between actual empty result, or "bad type". 

Essentially this looks like a hack, primarily becoz it depends on
functionality that cant be guaranteed to work after any bugfix submitted
by any contributor. If you want this functionality, you'll have to write
a more foolproof way into HSSFCell, and submit it in. Otherwise, you may
be able to implement this in your code, but it'll be very brittle. Just
my 2c.. not gospel :)

Regards
-
Avik


On Mon, 2004-07-19 at 20:52, Davinder Kohli wrote:
> I tried your approach, reading it as
> string(getStringCellValue) first. "" was returned. 
> When I read it as numeric, NaN is returned.
> 
> The formula stored is AND(A1,B1).
> Regards
> 
> --- "KHZ (SAW)" <ka...@sawag.com> wrote:
> > Hi Davinder.
> > 
> > Try it with first fetching the string value and
> > checking for 0. I think
> > the fetching the numeric value returns 0 and not
> > NaN.
> > 
> > I'ld expect that booleans are 0/1.
> > 
> > Regards,	Karl-Heinz.
> > 
> > 
> > -----Ursprüngliche Nachricht-----
> > Von: Davinder Kohli [mailto:kdavinder@yahoo.com] 
> > Gesendet: Montag, 19. Juli 2004 16:28
> > An: POI Users List
> > Betreff: Re: AW: formula return type
> > 
> > Thank you Karl.
> > That's exactly what I am doing. I wanted to go a
> > step
> > further and read in the contents of a cell
> > containing
> > a logical formula.
> > 1. When reading it as a string I get "", it would be
> > nice if I could read it as getBooleanCellValue().
> > 
> > 2. I also wanted to determine if the cell
> > (containing
> > a formula which returns numeric value) is of type
> > date.
> > 
> > double cellValue = theCell.getNumericCellValue();
> > if (Double.isNaN(cellValue)){
> >   // string value
> >   String strCell = theCell.getStringCellValue();
> > } else {
> >   // numeric
> >   ....
> > }
> > 
> > 
> > --- "KHZ (SAW)" <ka...@sawag.com>
> > wrote:
> > > Hi Davinder.
> > > 
> > > Actually you can query it as a numeric or a string
> > > value. If you've
> > > chosen the wrong type the result is "" or 0.
> > > Unfortunately you don't see
> > > the type. You just can look for the most
> > reasonable
> > > result.
> > > 
> > > Regards,	Karl-Heinz.
> > > 
> > > 
> > > -----Ursprüngliche Nachricht-----
> > > Von: Davinder Kohli [mailto:kdavinder@yahoo.com] 
> > > Gesendet: Freitag, 16. Juli 2004 22:36
> > > An: POI Users List
> > > Betreff: formula return type
> > > 
> > > Hi,
> > > How do I determine the return type of a formula?
> > Is
> > > there an API provided to do this or do I need to
> > > checkout the formula and then determine its return
> > > type.
> > > 
> > > Thanks,
> > > Davinder
> > > 
> > > 
> > > 		
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Mail - 50x more storage than other
> > providers!
> > > http://promotions.yahoo.com/new_mail
> > > 
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > poi-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > > poi-user-help@jakarta.apache.org
> > > 
> > > 
> > > 
> > > 
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > poi-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > > poi-user-help@jakarta.apache.org
> > > 
> > > 
> > 
> > 
> > 
> > 		
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - 50x more storage than other providers!
> > http://promotions.yahoo.com/new_mail
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > poi-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > poi-user-help@jakarta.apache.org
> > 
> > 
> > 
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > poi-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > poi-user-help@jakarta.apache.org
> > 
> > 
> 
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> Vote for the stars of Yahoo!'s next ad campaign!
> http://advision.webevents.yahoo.com/yahoo/votelifeengine/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org
> 


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


Re: AW: AW: formula return type

Posted by Davinder Kohli <kd...@yahoo.com>.
I tried your approach, reading it as
string(getStringCellValue) first. "" was returned. 
When I read it as numeric, NaN is returned.

The formula stored is AND(A1,B1).
Regards

--- "KHZ (SAW)" <ka...@sawag.com> wrote:
> Hi Davinder.
> 
> Try it with first fetching the string value and
> checking for 0. I think
> the fetching the numeric value returns 0 and not
> NaN.
> 
> I'ld expect that booleans are 0/1.
> 
> Regards,	Karl-Heinz.
> 
> 
> -----Urspr�ngliche Nachricht-----
> Von: Davinder Kohli [mailto:kdavinder@yahoo.com] 
> Gesendet: Montag, 19. Juli 2004 16:28
> An: POI Users List
> Betreff: Re: AW: formula return type
> 
> Thank you Karl.
> That's exactly what I am doing. I wanted to go a
> step
> further and read in the contents of a cell
> containing
> a logical formula.
> 1. When reading it as a string I get "", it would be
> nice if I could read it as getBooleanCellValue().
> 
> 2. I also wanted to determine if the cell
> (containing
> a formula which returns numeric value) is of type
> date.
> 
> double cellValue = theCell.getNumericCellValue();
> if (Double.isNaN(cellValue)){
>   // string value
>   String strCell = theCell.getStringCellValue();
> } else {
>   // numeric
>   ....
> }
> 
> 
> --- "KHZ (SAW)" <ka...@sawag.com>
> wrote:
> > Hi Davinder.
> > 
> > Actually you can query it as a numeric or a string
> > value. If you've
> > chosen the wrong type the result is "" or 0.
> > Unfortunately you don't see
> > the type. You just can look for the most
> reasonable
> > result.
> > 
> > Regards,	Karl-Heinz.
> > 
> > 
> > -----Urspr�ngliche Nachricht-----
> > Von: Davinder Kohli [mailto:kdavinder@yahoo.com] 
> > Gesendet: Freitag, 16. Juli 2004 22:36
> > An: POI Users List
> > Betreff: formula return type
> > 
> > Hi,
> > How do I determine the return type of a formula?
> Is
> > there an API provided to do this or do I need to
> > checkout the formula and then determine its return
> > type.
> > 
> > Thanks,
> > Davinder
> > 
> > 
> > 		
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - 50x more storage than other
> providers!
> > http://promotions.yahoo.com/new_mail
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > poi-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > poi-user-help@jakarta.apache.org
> > 
> > 
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > poi-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > poi-user-help@jakarta.apache.org
> > 
> > 
> 
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> http://promotions.yahoo.com/new_mail
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> poi-user-help@jakarta.apache.org
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> poi-user-help@jakarta.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!
http://advision.webevents.yahoo.com/yahoo/votelifeengine/


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


AW: AW: formula return type

Posted by "KHZ (SAW)" <ka...@sawag.com>.
Sorry.

Check the string value for "". I was thinking something else when
writing.

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: KHZ (SAW) [mailto:karl-heinz.zengerle@sawag.com] 
Gesendet: Montag, 19. Juli 2004 17:10
An: 'POI Users List'
Betreff: AW: AW: formula return type

Hi Davinder.

Try it with first fetching the string value and checking for 0. I think
the fetching the numeric value returns 0 and not NaN.

I'ld expect that booleans are 0/1.

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: Davinder Kohli [mailto:kdavinder@yahoo.com] 
Gesendet: Montag, 19. Juli 2004 16:28
An: POI Users List
Betreff: Re: AW: formula return type

Thank you Karl.
That's exactly what I am doing. I wanted to go a step
further and read in the contents of a cell containing
a logical formula.
1. When reading it as a string I get "", it would be
nice if I could read it as getBooleanCellValue().

2. I also wanted to determine if the cell (containing
a formula which returns numeric value) is of type
date.

double cellValue = theCell.getNumericCellValue();
if (Double.isNaN(cellValue)){
  // string value
  String strCell = theCell.getStringCellValue();
} else {
  // numeric
  ....
}


--- "KHZ (SAW)" <ka...@sawag.com> wrote:
> Hi Davinder.
> 
> Actually you can query it as a numeric or a string
> value. If you've
> chosen the wrong type the result is "" or 0.
> Unfortunately you don't see
> the type. You just can look for the most reasonable
> result.
> 
> Regards,	Karl-Heinz.
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Davinder Kohli [mailto:kdavinder@yahoo.com] 
> Gesendet: Freitag, 16. Juli 2004 22:36
> An: POI Users List
> Betreff: formula return type
> 
> Hi,
> How do I determine the return type of a formula? Is
> there an API provided to do this or do I need to
> checkout the formula and then determine its return
> type.
> 
> Thanks,
> Davinder
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> http://promotions.yahoo.com/new_mail
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> poi-user-help@jakarta.apache.org
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> poi-user-help@jakarta.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

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




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




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


AW: AW: formula return type

Posted by "KHZ (SAW)" <ka...@sawag.com>.
Hi Davinder.

Try it with first fetching the string value and checking for 0. I think
the fetching the numeric value returns 0 and not NaN.

I'ld expect that booleans are 0/1.

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: Davinder Kohli [mailto:kdavinder@yahoo.com] 
Gesendet: Montag, 19. Juli 2004 16:28
An: POI Users List
Betreff: Re: AW: formula return type

Thank you Karl.
That's exactly what I am doing. I wanted to go a step
further and read in the contents of a cell containing
a logical formula.
1. When reading it as a string I get "", it would be
nice if I could read it as getBooleanCellValue().

2. I also wanted to determine if the cell (containing
a formula which returns numeric value) is of type
date.

double cellValue = theCell.getNumericCellValue();
if (Double.isNaN(cellValue)){
  // string value
  String strCell = theCell.getStringCellValue();
} else {
  // numeric
  ....
}


--- "KHZ (SAW)" <ka...@sawag.com> wrote:
> Hi Davinder.
> 
> Actually you can query it as a numeric or a string
> value. If you've
> chosen the wrong type the result is "" or 0.
> Unfortunately you don't see
> the type. You just can look for the most reasonable
> result.
> 
> Regards,	Karl-Heinz.
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Davinder Kohli [mailto:kdavinder@yahoo.com] 
> Gesendet: Freitag, 16. Juli 2004 22:36
> An: POI Users List
> Betreff: formula return type
> 
> Hi,
> How do I determine the return type of a formula? Is
> there an API provided to do this or do I need to
> checkout the formula and then determine its return
> type.
> 
> Thanks,
> Davinder
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> http://promotions.yahoo.com/new_mail
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> poi-user-help@jakarta.apache.org
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> poi-user-help@jakarta.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

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




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


Re: AW: formula return type

Posted by Davinder Kohli <kd...@yahoo.com>.
Thank you Karl.
That's exactly what I am doing. I wanted to go a step
further and read in the contents of a cell containing
a logical formula.
1. When reading it as a string I get "", it would be
nice if I could read it as getBooleanCellValue().

2. I also wanted to determine if the cell (containing
a formula which returns numeric value) is of type
date.

double cellValue = theCell.getNumericCellValue();
if (Double.isNaN(cellValue)){
  // string value
  String strCell = theCell.getStringCellValue();
} else {
  // numeric
  ....
}


--- "KHZ (SAW)" <ka...@sawag.com> wrote:
> Hi Davinder.
> 
> Actually you can query it as a numeric or a string
> value. If you've
> chosen the wrong type the result is "" or 0.
> Unfortunately you don't see
> the type. You just can look for the most reasonable
> result.
> 
> Regards,	Karl-Heinz.
> 
> 
> -----Urspr�ngliche Nachricht-----
> Von: Davinder Kohli [mailto:kdavinder@yahoo.com] 
> Gesendet: Freitag, 16. Juli 2004 22:36
> An: POI Users List
> Betreff: formula return type
> 
> Hi,
> How do I determine the return type of a formula? Is
> there an API provided to do this or do I need to
> checkout the formula and then determine its return
> type.
> 
> Thanks,
> Davinder
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> http://promotions.yahoo.com/new_mail
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> poi-user-help@jakarta.apache.org
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> poi-user-help@jakarta.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

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


AW: formula return type

Posted by "KHZ (SAW)" <ka...@sawag.com>.
Hi Davinder.

Actually you can query it as a numeric or a string value. If you've
chosen the wrong type the result is "" or 0. Unfortunately you don't see
the type. You just can look for the most reasonable result.

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: Davinder Kohli [mailto:kdavinder@yahoo.com] 
Gesendet: Freitag, 16. Juli 2004 22:36
An: POI Users List
Betreff: formula return type

Hi,
How do I determine the return type of a formula? Is
there an API provided to do this or do I need to
checkout the formula and then determine its return
type.

Thanks,
Davinder


		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

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




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