Is it possible to fill crosstab cells with precalculated values?


Hello. I'm pretty new to JasperReports and I'd be glad if someone could help me with my question.

How is it possible to fill crosstabs' cells with precalculated values? I know that crosstabs support automatic calculations like "count", "average" et cetera - but my calculations depend on rather complex database queries so I cannot embed them directly into my JRXML file.

As a more concrete example, I want to fill these cells:

In this example, I would pass objects of the class Animal (containing only attributes and setters/getters for year and type) to the crosstab's dataset.
I thought about passing one extra field HashMap<String, HashMap<String, Integer>> to the report, filled with e.g.:

<"1999", HashMap<"Cows", calculateValue("1999", "Cow")>>
<"1999", HashMap<"Chickens", calculateValue("1999", "Chickens")>>
<"1999", HashMap<"Crabs", calculateValue("1999", "Crabs")>
<"2000", HashMap<"Cows", calculateValue("2000", "Cow")>>
<"2000", HashMap<"Chickens", calculateValue("2000", "Chickens")>
<"2000", HashMap<"Crabs", calculateValue("2000", "Crabs")>>
Then I would give my crosstab a dataset with $F{year} and $F{type} and use the <measurement> tag to access the HashMap by using these fields. But it seems that in the <measurement> tag of a crosstab I cannot access all dataset fields.
Is this possible in the first place?
randomdude946's picture
Joined: Oct 23 2015 - 5:43am
Last seen: 4 years 5 months ago

0 Answers:

No answers yet