poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shawn Laubach" <shawnlaub...@cox.net>
Subject RE: DataFormat of Cells
Date Sun, 30 Jan 2005 04:11:08 GMT
You could also use one of the 4 built in formats for money:
5, "($#,##0_);($#,##0)"
6, "($#,##0_);[Red]($#,##0)"
7, "($#,##0.00);($#,##0.00)"
8, "($#,##0.00_);[Red]($#,##0.00)"

To get them, do something like
oCS.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)")
); or if you want red use the one below it.

To see all built in formats go to
http://jakarta.apache.org/poi/apidocs/org/apache/poi/hssf/usermodel/HSSFData
Format.html and if you want a custom format you can look at the example in
the quick guide at
http://jakarta.apache.org/poi/hssf/quick-guide.html#DataFormats.

Shawn


-----Original Message-----
From: KHZ (SAW) [mailto:karl-heinz.zengerle@sawag.com] 
Sent: Friday, January 28, 2005 6:28 AM
To: 'POI Users List'
Subject: AW: DataFormat of Cells

Hi Mili.

It should be something similar to (adapt it to your needs)

oCS.setDataFormat(oFmt.getFormat("#,##0 \u0080"));

oCS is the HSSF cell style a and oFmt is the HSSF data format. Instead
of \u... (which was taken for Euro) you take your $ sign ($ should be a
standard ASCII character; I hope so).

If I remember it right 0 says that the output is mandatory. So you
format up to the maximum number of characters which can occur and add
the things behind the "." with 0. It's some time ago. So I hope I
remember it right.

Regards,	Karl-Heinz.


-----Urspr√ľngliche Nachricht-----
Von: Mili Aggarwal, Noida [mailto:milia@noida.hcltech.com] 
Gesendet: Freitag, 28. Januar 2005 12:34
An: POI Users List
Betreff: DataFormat of Cells

 

Hi All,
	An Excel sheet provides for formatting cells in "Accounting"
format.
Does POI provide any such feature?

Actually, my requirements wants me to display data in the form of
$xyz.ab,

Where, no of digits before decimal can be of any length but after the
decimal ONLY 2 digits are allowed but the String should be prefixed by
$.

Can anyone tell me how to accomplish the same ASAP.

Thanks a LOT in advance..


Warm Regards,
Mili Aggarwal

------------------------------------------------------------------------
----
-----------------------------DISCLAIMER---------------------------------
----
------------------------------------------------------------------------
----
---------

This message and any attachment(s) contained here are information that
is
confidential, proprietary to HCL Technologies and its customers.
Contents
may be privileged or otherwise protected by law. The information is
solely
intended for the individual or the entity it is addressed to. If you are
not
the intended recipient of this message, you are not authorized to read,
forward, print, retain, copy or disseminate this message or any part of
it.
If you have received this e-mail in error, please notify the sender
immediately by return e-mail and delete it from your computer.





---------------------------------------------------------------------
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/




---------------------------------------------------------------------
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/



---------------------------------------------------------------------
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/


Mime
View raw message