The number of explicit jasper reports for specific categories

I already tried to count cases of certain categories to which strings belong (see SQL-counting the occurrence of certain categories belonging to strings )

But now I'm wondering, can, without doing sql things, jasper reports capable of all this? do summaries on my own without providing additional work to the database server (what actually happens to me)?

For example, this could be a report that I have:

name | color | flavor -------------------------- n1 | green | lemon n2 | blue | strawberry n3 | red | lemon n4 | green | lemon n5 | green | mango n6 | red | chocolate n7 | white | lemon n8 | blue | mango n9 | green | chocolate 

And this will be the summary that I would like to receive:

 colors | occurrences flavor | occurences -------------------- ---------------------- green | 4 lemon | 4 blue | 2 strawberry| 1 red | 6 mango | 2 white | 1 chocolate | 2 
+4
source share
1 answer

You have 3 options:

  • You have 2 auxiliary reports and in each order choose according to color and taste. And in each summary report to summarize them as part of the master summer. When the SQL data comes to order, you can create a group in these columns in iReport and count each group in each variable. The disadvantage is that you go 2 times to DB for each additional report.

  • Have your own java data source implementation. It will just be like a data proxy not performing data conversion. Only the presence of a HashMap counting the appearance of color and taste. Then, as an additional field with the evaluation of the Report report, get these fields from the data source and get them in the report. You go to DB only once.

  • Combination with printing, if the expression and certain groups (color, taste) with printing, if the expression can help with the combination of ALL select statements:

    select a, b, c 'print_to_detail' as print_if_field, '' as dummy_field
    unification of all
    select a, b, c 'print_to_group1_summary' as print_if_field, color as dummy_field by color
    unification of all
    select a, b, c 'print_to_group2_summary' as print_if_field, and as dummy_field sorted by color

Perhaps this helps as a conceptual idea.

+2
source

Source: https://habr.com/ru/post/1447849/


All Articles