BTW, this code works perfectly if I do not use template and create new Excel file from scratch and it also works fine if I set the format to "0" or "0.00".
Here is my sample data: 55 54.5
I want to show them as below: 55.0 54.5
Here is the complete working code to reporduce this probelm: (I just modified the example from POI site)
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("workbook1.xls"));
HSSFWorkbook wb = new HSSFWorkbook(fs);HSSFSheet sheet = wb.createSheet("format sheet");
HSSFCellStyle style;
HSSFDataFormat format = wb.createDataFormat();
HSSFRow row;
HSSFCell cell;
short rowNum = 0;
short colNum = 0;row = sheet.createRow(rowNum++);
cell = row.createCell(colNum);
cell.setCellValue(111.256);
style = wb.createCellStyle();
style.setDataFormat(format.getFormat("0.0"));
cell.setCellStyle(style);FileOutputStream fileOut = new FileOutputStream("workbook2.xls");
wb.write(fileOut);
fileOut.close();
Thanks for any help, Sri
