Google Analytics

Tuesday, May 10, 2016

Jasper Reports - Customized field values for List

Jasper supports List of values in a single field. However jasper prints List<String> as below format.
(Jasper List of Values) Presentation

Print format of the Jasper - [aaa,bbb,ccc].

If you want to print above value line by line with additional horizontal dash line, you can modify your .jrxml field as below.

From java side field value sends :

List<String> xxx = new List<String>;
String d = "xx1"+"("+"ssss"+")"+ "-"+Date+"/"+"OOO";
String e = "xx2"+"("+"vvvv"+")"+ "-"+Date+"/"+"HHH";
String f = "xx3"+"("+"hhhh"+")"+ "-"+Date+"/"+"KKK";

xxx.add(d);
xxx.add(e);
xxx.add(f);

--------------------------------------------------------------------------------------------
In Jrxml

($F{xxx}.substring(1, $F{xxx}.length() - 1 )).replaceAll( ",", System.getProperty("line.separator")+"-----------------------------------------------"+ System.getProperty("line.separator"))


-------------------------------------------------------------------------------------------------

Out put:

xx1 (ssss) - 03/11/2015 / OOO
-----------------------------------------------
 xx2 (vvvv) - 05/10/2015 / HHH
----------------------------------------------- 
xx3 (hhhh) - 02/08/2015 / KKK



No comments:

Post a Comment