Formatting currency in Jasper Reports using pattern

浪子不回头ぞ 提交于 2019-12-01 20:11:11

You were close

<textField pattern="¤ #,##0.00">

should work.

You need the "¤" character to make it a "currency" format.

If you download iReports with a version number that matches your server you find out what your options are.

if you want to display currency symbol in $ and currency code is USD use the following pattern in jasper report. pattern = $ #,##0.00

It might depend on your version of Jasper.

On 3.7.6 I found that specifying the textFieldExpression class as java.util.BigDecimal meant that the pattern isn't applied. Maybe that version of Jasper doesn't realise it is a number.

If you choose instead specify the textFieldExpression class as being "java.lang.Number", it will use the pattern when you pass a BigDecimal in.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!