I want to format some cells with a comma as a thousands separator. For instance:
12 -> 12 1200 -> 1,200 12000 -> 12,000 12000000 -> 12,000,000 120000000 -> 120,000,000
I have the following code. What should be used as formatStr
? Is there an easy way? Or do I need to determine the number of zeros in order to create something like this #,###,###
?
String formatStr = ""; HSSFCellStyle style = workbook.createCellStyle(); HSSFDataFormat format = workbook.createDataFormat(); style.setDataFormat(format.getFormat(formatStr)); cell.setCellStyle(style); cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
Keep in mind that I am dealing with numbers. The cell type will be numeric, not string.
Update

alkis source share