有没有一种格式可以使用Apache poi设置千位分隔符并设置两位小数?

huangapple go评论63阅读模式
英文:

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

问题

我可以这样设置成千上运算符:

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

或者设置两位小数:

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

有没有设置同时包含两者的选项呢?

英文:

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?

答案1

得分: 1

这对我而言是有效的:

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

基于 @Fullslack.dev 评论找到了解决方案:https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/BuiltinFormats.html

英文:

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

huangapple
  • 本文由 发表于 2020年9月21日 20:46:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/63992561.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定