You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Dale Monti <dm...@linoma.com> on 2004/06/17 17:08:40 UTC

Applying a FormatRecord to a NumberRecord?

Hi,
I am reading through a spread sheet using the eventmodel to process a spread sheet. I have a NumberRecord and I have a FormatRecord and would like to get the string as it appears in Excel. 
For example the value of the NumberRecord is 38068.0 the value of FormatRecord.getFormatString() is mmmm\ d\,\ yyyy. 
In Excel the value appears as March 22, 2004.

How do I achieve the same result using POI?

Thanks
Dale

Re: Applying a FormatRecord to a NumberRecord?

Posted by Dale Monti <dm...@linoma.com>.
After some digging I found the following class that was helpful.
src\contrib\src\org\apache\poi\hssf\contrib\view\SVTableCellRenderer.java

----- Original Message ----- 
From: "Dale Monti" <dm...@linoma.com>
To: "POI Users List" <po...@jakarta.apache.org>
Sent: Thursday, June 17, 2004 11:16 AM
Subject: Re: Applying a FormatRecord to a NumberRecord?


> I am looking for a generic way to apply FormatRecord.getFormatString() to
a
> NumberRecord value. Not just for dates.
> Something like:
> String getFormattedString(double d, FormatRecord fr)
>
> Where you pass in any value it returns the String as you see it in Excel.
>
> Thanks
> ----- Original Message ----- 
> From: "Jenny Liu" <je...@totaletl.com>
> To: "'POI Users List'" <po...@jakarta.apache.org>
> Sent: Thursday, June 17, 2004 10:47 AM
> Subject: RE: Applying a FormatRecord to a NumberRecord?
>
>
> > See the link:
> > http://javaalmanac.com/egs/java.text/FormatDate.html
> >
> >     formatter = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
> >     s = formatter.format(date);
> >     // 2002.01.29.08.36.33
> >
> > -----Original Message-----
> > From: Dale Monti [mailto:dmonti@linoma.com]
> > Sent: Thursday, June 17, 2004 11:09 AM
> > To: poi-user@jakarta.apache.org
> > Subject: Applying a FormatRecord to a NumberRecord?
> >
> > Hi,
> > I am reading through a spread sheet using the eventmodel to process a
> > spread sheet. I have a NumberRecord and I have a FormatRecord and would
> > like to get the string as it appears in Excel.
> > For example the value of the NumberRecord is 38068.0 the value of
> > FormatRecord.getFormatString() is mmmm\ d\,\ yyyy.
> > In Excel the value appears as March 22, 2004.
> >
> > How do I achieve the same result using POI?
> >
> > Thanks
> > Dale
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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


Re: Applying a FormatRecord to a NumberRecord?

Posted by Dale Monti <dm...@linoma.com>.
I am looking for a generic way to apply FormatRecord.getFormatString() to a
NumberRecord value. Not just for dates.
Something like:
String getFormattedString(double d, FormatRecord fr)

Where you pass in any value it returns the String as you see it in Excel.

Thanks
----- Original Message ----- 
From: "Jenny Liu" <je...@totaletl.com>
To: "'POI Users List'" <po...@jakarta.apache.org>
Sent: Thursday, June 17, 2004 10:47 AM
Subject: RE: Applying a FormatRecord to a NumberRecord?


> See the link:
> http://javaalmanac.com/egs/java.text/FormatDate.html
>
>     formatter = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
>     s = formatter.format(date);
>     // 2002.01.29.08.36.33
>
> -----Original Message-----
> From: Dale Monti [mailto:dmonti@linoma.com]
> Sent: Thursday, June 17, 2004 11:09 AM
> To: poi-user@jakarta.apache.org
> Subject: Applying a FormatRecord to a NumberRecord?
>
> Hi,
> I am reading through a spread sheet using the eventmodel to process a
> spread sheet. I have a NumberRecord and I have a FormatRecord and would
> like to get the string as it appears in Excel.
> For example the value of the NumberRecord is 38068.0 the value of
> FormatRecord.getFormatString() is mmmm\ d\,\ yyyy.
> In Excel the value appears as March 22, 2004.
>
> How do I achieve the same result using POI?
>
> Thanks
> Dale
>
>
>
> ---------------------------------------------------------------------
> 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: Applying a FormatRecord to a NumberRecord?

Posted by Jenny Liu <je...@totaletl.com>.
See the link:
http://javaalmanac.com/egs/java.text/FormatDate.html

    formatter = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
    s = formatter.format(date);
    // 2002.01.29.08.36.33

-----Original Message-----
From: Dale Monti [mailto:dmonti@linoma.com] 
Sent: Thursday, June 17, 2004 11:09 AM
To: poi-user@jakarta.apache.org
Subject: Applying a FormatRecord to a NumberRecord?

Hi,
I am reading through a spread sheet using the eventmodel to process a
spread sheet. I have a NumberRecord and I have a FormatRecord and would
like to get the string as it appears in Excel. 
For example the value of the NumberRecord is 38068.0 the value of
FormatRecord.getFormatString() is mmmm\ d\,\ yyyy. 
In Excel the value appears as March 22, 2004.

How do I achieve the same result using POI?

Thanks
Dale



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