在iReport 5.7.0中设置数字格式模式以保留小数点后3位数字 [英] Setting a number format pattern in iReport 5.7.0 to retain 3 digits after the decimal point

查看:497
本文介绍了在iReport 5.7.0中设置数字格式模式以保留小数点后3位数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 iReport 5.7.0 生成 JasperReports 的报告.
我在具有Double值的字段上设置了模式##### 0.000.
我期望小数点后三位,但是如果数字没有小数部分,那么实际上只显示小数点后的一个零.
即我得到了什么 `4.56678 => 4.566
4.0 => 4.0 4.1 => 4.000

I am using iReport 5.7.0 to generate JasperReports's report.
I have set the pattern #####0.000 on a field with a Double value.
I have expected 3 decimal places But actually Only one zero after the decimal point is displayed if the number has no decimal part .
i.e , what I get `4.56678 =>4.566
4.0 =>4.0 4.1 => 4.000

我想要什么 4.5667888 => 4.566 4.0 => 4.000 4.1 => 4.000`

What I want 4.5667888 =>4.566 4.0 =>4.000 4.1 =>4.000 `

请帮忙吗?

推荐答案

在需要特定十进制格式的位置尝试以下内容.假设您有一个要报告的字段,Total_Number:

Try following at the place where you want a particular decimal format. Say you have a field into report, Total_Number:

new DecimalFormat("#0.000").format($F{Total_number})

如果$ F {Total_number}的值为4.5667888.以下是输出:

If the value for $F{Total_number} is 4.5667888. Following is the output:

输出

4.566

这篇关于在iReport 5.7.0中设置数字格式模式以保留小数点后3位数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆