lundi 20 avril 2015

Not able to apply specific cell data format using POI

I am using Apache poi to write data into excel. I am trying to write big decimal number to an excel cell and i am using the following methods to achieve..

> 1.        CellStyle style= wb.createCellStyle();
            style.setDataFormat(df.getFormat("000.0000000"));

    2.      CellStyle style= wb.createCellStyle();
    .       HSSFCreationHelper createHelper = wb.getCreationHelper();
            style.setDataFormat(
            createHelper.createDataFormat().getFormat("000.0000000"));

Below is the required Format:

0.0000000--->000.0000000
1.0000000--->001.0000000
10.0000000--->010.0000000
101.0068721--->101.0068721
111.0034360--->111.0034360
010.0034526--->010.0034526
100.1452672--->100.1452672

But i am ending up with the below output using above data format

0.0000000  --->   000.0000000
1.0000000--->    000.0000000
10.0000000--->000.0000000
101.0068721--->000.0068721
111.0034360--->000.0000000
010.0034526--->000.0034526
100.1452672--->000.1452672 

Please suggest me the correct data format. Thanks in advance :)

Aucun commentaire:

Enregistrer un commentaire