Nem Jov
Nem Jov

Reputation: 25

Is there a format to set thousand separator and also set two decimal places using Apache poi?

I can either set thousand operator like this:

cell.getCellStyle().setDataFormat(HSSFDataFormat.getBuiltinFormat("#,#00"));

Or set two decimal places:

cell.getCellStyle().setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00"));

Is there an option to set both?

Upvotes: 0

Views: 1051

Answers (1)

Nem Jov
Nem Jov

Reputation: 25

This worked for me:

cell.getCellStyle().setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));

Found solution based on @Fullslack.dev comment https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/BuiltinFormats.html

Upvotes: 1

Related Questions