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/21 21:50:58 UTC
Applying HSSFDataFormat to a value.
Hi,
I am reading a spread sheet and would like to display the formatted cell the same way it appears in Excel. For example in Excel the value appears as $30.00.
HSSFCell cell
HSSFDataFormat format = book.createDataFormat();
I use cell.getNumericCellValue() which returns 30.0 and
format.getFormat(cell.getCellStyle().getDataFormat()) which returns ($#,##0.00);($#,##0.00)
How to I put them together to get $30.00 ?
I would really appreciate a response, even if the response is 'you can't do that'.
Thanks in advance
Re: Applying HSSFDataFormat to a value.
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: Monday, June 21, 2004 2:50 PM
Subject: Applying HSSFDataFormat to a value.
Hi,
I am reading a spread sheet and would like to display the formatted cell the
same way it appears in Excel. For example in Excel the value appears as
$30.00.
HSSFCell cell
HSSFDataFormat format = book.createDataFormat();
I use cell.getNumericCellValue() which returns 30.0 and
format.getFormat(cell.getCellStyle().getDataFormat()) which returns
($#,##0.00);($#,##0.00)
How to I put them together to get $30.00 ?
I would really appreciate a response, even if the response is 'you can't do
that'.
Thanks in advance
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org
Re: creating fonts
Posted by Avik Sengupta <av...@itellix.com>.
Styles are always created anew, and its the application writers
responsibility to track and cache them. I would imagine font objects
behave similarly, cant be sure without checking the code.
On Tue, 2004-06-22 at 04:30, Chris Cheshire wrote:
> If I create a font in a workbook, does it always crate a new instance of
> a font, or is there some internal mechanism that keeps track of what has
> been created?
>
> For instance, if I create a font in a workbook that is Arial, 10pt,
> bold, left justified does it always create a new instance of a font with
> these attributes, or does it create an instance at first, and
> subsequently return a reference to the previously created font in the
> font table?
>
> Chris
>
>
> ---------------------------------------------------------------------
> 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
(was creating fonts) now findFont(...)
Posted by Chris Cheshire <cc...@bigredwire.com>.
OK so I grabbed the CVS tree for poi to have a look myself and the short
answer is no, it creates a new font.
However directly underneath it is a method called findFont that is not
in the javadoc published on the web. It contains a lot of System.out
calls, so is this a work in progress? (I don't particularly want the poi
debug stuff in my log files)
Also, out of curiosity, there what is up with the index 4 in the font
table? There is code in there to skip it. Why is this?
Thanks
Chris
Chris Cheshire wrote:
> If I create a font in a workbook, does it always crate a new instance of
> a font, or is there some internal mechanism that keeps track of what has
> been created?
>
> For instance, if I create a font in a workbook that is Arial, 10pt,
> bold, left justified does it always create a new instance of a font with
> these attributes, or does it create an instance at first, and
> subsequently return a reference to the previously created font in the
> font table?
>
> Chris
>
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org
creating fonts
Posted by Chris Cheshire <cc...@bigredwire.com>.
If I create a font in a workbook, does it always crate a new instance of
a font, or is there some internal mechanism that keeps track of what has
been created?
For instance, if I create a font in a workbook that is Arial, 10pt,
bold, left justified does it always create a new instance of a font with
these attributes, or does it create an instance at first, and
subsequently return a reference to the previously created font in the
font table?
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org
AW: Applying HSSFDataFormat to a value.
Posted by "KHZ (SAW)" <ka...@sawag.com>.
Hi Dale.
It's something similar to
oCS.setDataFormat(oFmt.getFormat("dd.MM.yyyy"));
(just adapted to your format; numbers we didn't have to format up to
yet).
So you just should replace my date format above by your number format
below.
Regards, Karl-Heinz.
-----Ursprüngliche Nachricht-----
Von: Dale Monti [mailto:dmonti@linoma.com]
Gesendet: Montag, 21. Juni 2004 21:51
An: POI Users List
Betreff: Applying HSSFDataFormat to a value.
Hi,
I am reading a spread sheet and would like to display the formatted cell
the same way it appears in Excel. For example in Excel the value appears
as $30.00.
HSSFCell cell
HSSFDataFormat format = book.createDataFormat();
I use cell.getNumericCellValue() which returns 30.0 and
format.getFormat(cell.getCellStyle().getDataFormat()) which returns
($#,##0.00);($#,##0.00)
How to I put them together to get $30.00 ?
I would really appreciate a response, even if the response is 'you can't
do that'.
Thanks in advance
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org