You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Siva Kumar <sk...@gmail.com> on 2008/06/05 21:19:43 UTC

Decimal places - cell format

I want to set the number of decimal places in the generated excel. How to
set the number of decimal places through poi 3.0.1?

Thanks in advance

Siva

Re: Decimal places - cell format

Posted by Siva Kumar <sk...@gmail.com>.
Thank you very much. Mislead by the method name setDateFormat. Solves one of
my requirements, no decimal places. But I did not find a format for numeric
with 4 decimal places...

Thanks
Siva

On 6/6/08, Nick Burch <ni...@torchbox.com> wrote:
>
> On Thu, 5 Jun 2008, Siva Kumar wrote:
>
>> I want to set the number of decimal places in the generated excel. How to
>> set the number of decimal places through poi 3.0.1?
>>
>
> http://poi.apache.org/hssf/quick-guide.html#DataFormats
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: Decimal places - cell format

Posted by Nick Burch <ni...@torchbox.com>.
On Thu, 5 Jun 2008, Siva Kumar wrote:
> I want to set the number of decimal places in the generated excel. How 
> to set the number of decimal places through poi 3.0.1?

http://poi.apache.org/hssf/quick-guide.html#DataFormats

Nick

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


Re: Decimal places - cell format

Posted by Sanjiv Jivan <sa...@gmail.com>.
I realize this is an old thread but thought I'd post a solution that I'm
using since I found it hard to find.

HSSFWorkbook wb = ...
HSSFDataFormat df = wb.createDataFormat();
short dataFormat = df.getFormat("0.0000"); //can also use a format like
"0.00##" if you don't want extra decimal places to display when they don't
exist

HSSFCellStyle style = wb.createCellStyle();
style.setDataFormat(dataFormat);

Sanjiv

On Thu, Jun 5, 2008 at 3:19 PM, Siva Kumar <sk...@gmail.com> wrote:

> I want to set the number of decimal places in the generated excel. How to
> set the number of decimal places through poi 3.0.1?
>
> Thanks in advance
>
> Siva
>