You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Sanjiv Jivan <sa...@gmail.com> on 2010/03/26 21:16:09 UTC

Re: Decimal places - cell format

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
>