Jump to content
We've recently updated our Privacy Statement, available here ×

suppressing leading zeroes ...


2006 IR Open Dicussion

Recommended Posts

By: Tony - tt_linux

suppressing leading zeroes ...

2006-07-16 07:01

hi,

 

I have a field (string) that has leading zeroes.

How can i suppress the leading zeroes ?

Eg. "0001" should be just "1"

 

Help most appreciated. Thanks

 

Tony

 

 

 

 

 

By: Javy Dreamer - javydreamercsw

RE: suppressing leading zeroes ...

2006-07-16 18:04

Try something like:

 

new Integer().valueof($F{field_name})

 

in the field expression. make sure to make the Field of the integer type.

 

I'm not really sure if it works. I don't have iReport in my laptop. I'll try it when I get at work on monday and let you know. If you try it befor let me know.

 

 

 

 

 

 

By: Tony - tt_linux

RE: suppressing leading zeroes ...

2006-07-16 19:06

hi Javy,

 

i did:

1. set the field type to java.lang.integer

2. type in the above syntax. compile error.

 

 

 

 

By: Tony - tt_linux

RE: suppressing leading zeroes ...

2006-07-16 19:10

hi,

 

BTW, the database field is in String, incase if you

are wondering ...

 

Only the report field $F{} is changed to Integer type in the above post.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I had to create a report that detected trailing spaces, and I find the most straightforward and flexible way to do things like this is to use a report scriptlet. Just create a small report scriptlet to process your field however you want then pass the field into it:

 

$P{REPORT_SCRIPTLET}.truncateleadingzero($F{YOURFIELD})

 

this gives you a lot of power in formatting text just the way you want it, and still seems to be pretty fast unless you are doing something really intensive.

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