如何在JasperSoft Studio中将数字格式化为2.564.894.621? [英] How do I format a number as 2.564.894.621 in JasperSoft Studio?

查看:518
本文介绍了如何在JasperSoft Studio中将数字格式化为2.564.894.621?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打印一些重要的值。值如下所示


2564894621


现在我想将浮点值格式化为:


2.564.894.621


我使用Jaspersoft Studio开发我的jasper报告。

解决方案

在jasper报告中格式化的最佳方法是使用 textField 标记上的模式属性。这将保持正确的类(数字),当导出到例如excel时,excel可以将其标识为数字并且也将应用相同的模式。


属性>> TextField >> Pattern


要么你知道正确的



jrxml结果

 < textField pattern =#,## 0> 
< reportElement x =0y =0width =200height =25uuid =ee49d149-394b-4ac6-a0a2-6d207b0c8d89/>
< textElement>
< font fontName =DejaVu Serifsize =14/>
< / textElement>
< textFieldExpression><![CDATA [$ F {myNumber}]]>< / textFieldExpression>
< / textField>

使用导出区域设置作为分组分隔符,它将显示



< img src =https://i.stack.imgur.com/TeuNm.pngalt =结果>



如果您的结果是分组分隔符这不依赖于模式,只是您的区域设置看到:如何在数字格式化时反转逗号和点数



JasperSoft Studio 中,预览期间使用的语言环境可以设置为


窗口>>首选项>>报表执行:区域设置


注意:表达式如

 < textFieldExpression>< ; [CDATA [new DecimalFormat(#,## 0)。format($ F {myNumber})]]> < / textFieldExpression> 

也可以使用,但最好避免,因为出口经理将此视为仅限文字


I need to print some big values. A value looks like this

2564894621

now I want to format the float value to this:

2.564.894.621

I am using Jaspersoft Studio to develop my jasper report.

解决方案

The best way to format in jasper report is to use the pattern attribute on the textField tag. This will keep correct class (Number), when exporting to for example excel, excel can identify it as number and will also apply same pattern.

Properties >> TextField >> Pattern

Either you know the correct pattern or you use the IDE to help you generate it

jrxml result

<textField pattern="#,##0">
   <reportElement x="0" y="0" width="200" height="25" uuid="ee49d149-394b-4ac6-a0a2-6d207b0c8d89"/>
   <textElement>
      <font fontName="DejaVu Serif" size="14"/>
    </textElement>
    <textFieldExpression><![CDATA[$F{myNumber}]]></textFieldExpression>
</textField>

And exporting with a Locale that uses . as grouping separator it will display

if your result is with the grouping separator , this does not depend on the pattern but simply your locale see this: How to invert the comma and dot when number formatting

In JasperSoft Studio the locale used during preview can be set in

Window>>Preferences>>Report Execution: Locale

Note: expression like

<textFieldExpression><![CDATA[new DecimalFormat("#,##0").format($F{myNumber})]]></textFieldExpression>

can be used as well but its better to avoid since the export manager will treat this as text only

这篇关于如何在JasperSoft Studio中将数字格式化为2.564.894.621?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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