For example,
XSSFCellStyle style=(XSSFCellStyle) workbook.createCellStyle();
style.setDataFormat(workbook.createDataFormat().getFormat(\"#.##\"));
productCe
This one worked for me:
Set Cell Style
private CellStyle formatDecimalStyle(Workbook workbook, CreationHelper createHelper) {
CellStyle style = workbook.createCellStyle();
style.setDataFormat(createHelper.createDataFormat().getFormat("0.00"));
return style;
}
Apply Style on Cell
CellStyle style = formatDecimalStyle(workbook, createHelper);
Cell creditAmountCell = row.createCell(3);
creditAmountCell.setCellValue(amount);
creditAmountCell.setCellStyle(style);