Apache poi - Thousand separator

Do you know how I can set a thousand separators and have a value formatted like this? 403.000

I am using apache-poi 3.8 with Java. I searched a lot for it, but could not find an answer. I cannot use a string value because my formulas are not being evaluated correctly in this way. Any help? thanks!

I tried something like this:

 cellStyle.setDataFormat(creationHelper.createDataFormat().getFormat("#.##0")); 

but it does not work.

+4
source share
2 answers

Ok, I found: the format should be as follows: "#,##0"

+4
source

You can do it:

  final HSSFCell dataCell = dataRow.createCell(1); dataCell.getCellStyle().setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0")); dataCell.setCellValue(123456); 

You will have a cell with the display number as follows: 123.456 The second of thousands depends on the language and, possibly, on the excel language.

+6
source

Source: https://habr.com/ru/post/979397/


All Articles