Reputation: 867
I have a problem with JasperReports. I am passing string values to a report. A specific code has included to each and every value that I’m passing, like “pre: 001”, “ab: 002”, “lv: 003”.
Codes - “pre”,”ab”,”lv”
As I mentioned above, each code and value can separately identify by “:” notation. In Java I used following code to separate the code and value;
a = “pre:001”;
String[] b = a.Split(“:”,2);
System.out.println(b[0]); // code
System.out.println(b[1]); // value
Problem
I need to pass combined value (code+value) to the report but the text field should only appear the value portion.
Ex:
Input – “pre:010”
Output-“010”
Upvotes: 1
Views: 15658
Reputation: 779
To split a field 'fieldname' with '|' delimiter and get first element
$F{fieldname}.toString().split("\\|")[0]
Upvotes: 2
Reputation: 24630
That should be in the text field expression
for field A
:
$F{A}.split(":",2)[1].trim()
Upvotes: 3
Reputation: 966
If you are using irport add expression to your text field like {fieldName}.substring() from property menu.
Upvotes: 0