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

Is it possible to fill crosstab cells with precalculated values?


randomdude946

Recommended Posts

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:

cows.png.7aee9515d16f8604cdba820293d02f04.png

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?[/code]

cows.png.616b3ad6a27b102c225ff956af5d9129.png

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

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