I am trying to create Jasper Report with crosstab by writing JRXML with DTOs.
I am trying to create rows dynamic number of chargeCodes and their total. It looks something like this:
jobNo | chargeCodeA | chargeCodeB | Total |
---|---|---|---|
jobNoABC | 100.10 | 300.30 | 400.40 |
jobNoDEF | 200.20 | 400.40 | 600.60 |
In my Java backend, I have DTO which looks like this
class MyDTO { private String jobNo; private List <String> chargeCode = new ArrayList <> (); private List <BigDecimal> chargeCodeTotal = new ArrayList <> (); }
where the list codeCode contains chargeCodeA, chargeCodeB for jobNoABC
and chargeCodeTotal contains 100.10, 300.30 for jobNoABC also.
In my JRXML, I have included in sample.jrxml
But I am getting error:
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Comparable at org.apache.commons.collections.comparators.ComparableComparator.compare(ComparableComparator.java:91)
I am not sure how to create infinite number of chargeCodes using JRXML.
And I cannot use Dynamic Jasper. I can only think of crosstab. Please help. Thanks.
Did you find any solution?