Reputation: 1317
Do you know how can I set the thousand sepator and have a value formatted like this? 403.000
I'm using apache-poi 3.8 with Java. I googled it a lot but I didn't find an answer. I can't use a string value because my formulas are not evaluated correctly in this way. Any help? thanks!
I've tried something like this:
cellStyle.setDataFormat(creationHelper.createDataFormat().getFormat("#.##0"));
but it doesn't work..
Upvotes: 10
Views: 12273
Reputation: 1317
Answering my own question for everyone else who might have the same issue.
found it: the format must be: "#,##0"
dataCell.getCellStyle().setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0"));
Upvotes: 10
Reputation: 1190
You can do this:
final HSSFCell dataCell = dataRow.createCell(1);
dataCell.getCellStyle().setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0"));
dataCell.setCellValue(123456);
You'll have a cell with the number display like this: 123.456 The thousand separator depends of the locale and perhaps of the language of excel.
Upvotes: 8