adding Leading zeros to a numeric field

0

How in Jaspersoft Server can I change 12.34 to 00000012.34 please?

keith.crown's picture
Joined: Feb 16 2018 - 6:34am
Last seen: 2 weeks 14 hours ago

What's the data type of 12.34? String ? float?

A3an - 2 weeks 4 hours ago

2 Answers:

0

You can convert the number to a string and prefix with your zeros.

"00000" + $F{MyFloat}.toString() 

jgust's picture
248
Joined: Jun 10 2010 - 6:39am
Last seen: 1 day 9 hours ago
0

JasperSoft Studio has the TEXT function which you can use in the "Text Field" like this...

TEXT($F{QR},"000000")

Here the field QR is an integer, and the TEXT function converts it to a value with the "right number" of leading zeroes.

For example, if QR = 1037, then you'd get 001037 from the function.

HOWEVER...

If it's floating point you need, then the other answer works.

ALSO

On the Text Field property, there's an entry called "Pattern"

There you can pretty much play with formats kind of like in Excel.

andrew_50's picture
Joined: Jan 25 2018 - 8:33am
Last seen: 6 days 8 hours ago
Feedback
randomness