Preprocessing the records before printing in Jasper report

0
I have been trying to come up with a simple solution to the problem below.
Given the input parameters, the query returns result which needs to be kind of transposed and displayed in jasper report.
Would be great to get some pointers on same.
 
Input params: Comma separated list of Accounts eg. A,B,C
Acc1 Acc2 Percent_Acc1_acc2
Query Output
A A 100%
A B 40%
A C 30%
B A 20%
B B 100%
B C 45%
C A 33%
C B 12%
C C 100%

 

Acc1 A B C
Desired Jasper report Output
A 100% 40% 30%
B 20% 100% 45%
C 33% 12% 100%

 

 

 

The account list is dynamic i.e. can be more than 3.

Hence the columns will increase as well as the number of rows.

I am trying to put based on following approaches.. however not getting a starting point.

1) preprocessing to be done before printing the results. A variable like ArrayList or Array of integers containing all the elements.. eg. 9 elements in above case.

Then while iterating thr the elements, their positions can be derived and placed in another variable set. (May be object)

And final iteration of new variable will be the report printed.

2) putting scriptlet which will run the query and format the results.

3) Generate the excel first and then apply macro to result.

Unfortunately this is not allowed by users.

Any guidance on the approach is appreciated.

 

 

 

sach411's picture
Joined: Mar 26 2015 - 10:51am
Last seen: 1 year 1 month ago

3 Answers:

0

Hey,

 

Have you tried using a crosstab, I think that will serve the purpose you need.

Hope that this helps.

 

Thanks
Ankur Gupta

Ankur Gupta's picture
Joined: Jan 21 2013 - 10:36pm
Last seen: 1 month 5 days ago
0

thanks Ankur for the pointer. Will checkout the cross tab option.

sach411's picture
Joined: Mar 26 2015 - 10:51am
Last seen: 1 year 1 month ago
0

Thanks Ankur.

Using crosstab this was achievable. 

sach411's picture
Joined: Mar 26 2015 - 10:51am
Last seen: 1 year 1 month ago
Feedback
randomness