Jump to content
Changes to the Jaspersoft community edition download ×

Number Format


Recommended Posts

By: Yaddif - yaddif

Number Format

2006-03-27 13:59

Hi Friends,

 

I have a problem with the number format at Jasper. It is not taken the "regional setting" from Linux.

 

I want to the numbers be shown as : 333,333.33 but when I run jasper at linux it shows : "333.333,33" :(.

 

How can i force the jasper (with a function or something) in order to shows the number as the way that I want without care the server where it is running?

 

(This problem was happened in Java too, but I solved using the DecimalFormat with the US Locale, but i dont know how apply this in Jasper).

 

Thanks in advance.

 

 

By: Sanjeev Saha - sanjeevsaha

RE: Number Format

2006-03-27 14:08

2 approaches:

 

1) Create your own formatter class that takes in the desired parameters and returns the required format. Import this class in your jasper report and use it as any other java class while displaying the values.

 

2) Use the Jasper scriptlet support. You can checkout an example of how to do this by downloading the jasper reports source, in the demo/samples/scriptlet folder.

 

hth,

Sanjeev

 

 

By: Lucian Chirita - lucianc

RE: Number Format

2006-03-28 08:25

Hi

 

If the default Java locale is not good for you, you can set the REPORT_LOCALE parameter to any explicit value at fill time and the number format will be created for the specific locale.

 

HTH,

Lucian

 

 

By: Yaddif - yaddif

RE: Number Format

2006-03-28 08:19

Thanks Sanjeev for your help.

 

I think that the best option is the first because i can centralized my format function(for all my reports), but do you have some examples for import my class (and execute my method) inside the jasper xml file?... because i remember that i tried to do this but I couldn't.

 

Thanks again for your help.

 

Yaddif.

 

 

By: Sanjeev Saha - sanjeevsaha

RE: Number Format

2006-03-28 08:34

If you were to build the report as a jrxml, then you'll need the import entry to identify the formatter class:

 

<import value="x.y.z.NumberFormatter" />

 

Now, inorder to actually use this class, a simple example could be:

 

<variable name="some_value" class="java.lang.String">

<variableExpression><![CDATA[NumberFormatter.format($F{filed_name})]]></variableExpression>

</variable>

 

You get the idea ;-)

 

hth,

Sanjeev

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...