Jump to content

Jasper Reports doesn't format number when running report from Java code

Go to solution Solved by Ankur Gupta,

Recommended Posts

I've created report using iReport 4.5.1 which contains tables with fields of amount values. Value of "Pattern" property of these fields is "$ #,##0.00". When I run report from iReport I see right formatted amount, but when I run report from Java code (library version is 5.0.0), I see same amounts but without formatting. Why formatting disappears when I run report from Java code? How to fix it?

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

Hi tural,

The formatting done in the iReport is report specific it like extra utility , of providing the pattern provided by the iReport. When you run that in java code the formatting is removed. So what you can do for the java code is that you could use:

 new java.text.DecimalFormat("pattern").format(put the field here)


So to provide similarity in the report and in the Java code what can be done is that you could replace the expression of the text field with the same expression and the discrepancy could be easily taken care off.In that case the expression would look something like this

 new java.text.DecimalFormat("¤ #,##0").format($F{VALUE})   

Now here the in the field expression easily , any field or parameter could be put and same would work fine for java code too,


Hope that it solves your query




Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...