The cell format "0.00" seems not work

May 19, 2011 at 7:56 AM
Edited May 19, 2011 at 7:59 AM

Hi,

I was wondering if the format "0.00" doesn't work perfectly or I used it in the wrong way.

My code is

HSSFCellStyle cellStyle = (HSSFCellStyle)hssfworkbook.CreateCellStyle();
cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("0.00");

Row row = sheet1.CreateRow(i);
row.CreateCell(j).SetCellValue("1.1");
row.GetCell(j).CellStyle = cellStyle;

I am using Office 2007 and expect to have "1.10" but only get "1.1" in the Excel file.

Can anybody tell me why?Any answer weill be appreciated

Coordinator
May 26, 2011 at 3:14 AM

Try this code:

row.CreateCell(j).SetCellValue(1.1);