Jump to content

Dynamic coloums in the reports


nsanagari

Recommended Posts

 

Hi,

      From the last few days i am workin on the Jasper reports and ireports using the JavaBean Set data source.

     I can generate the report which has static coloums in the report. I dont know how to generate report which has dynamic colouns based on the data given to the report.

    Can any one tell me how to generate the report which has dynamic colouns.

 

Thanking you,

NIRANJAN REDDY. S

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

it sounds like you will need to use a crosstab. The crosstab will generate a dynamic number of columns that are based on what type of value you use horizontaly.  For example if you have a POJO with values:

String month

String typeOfIncident

 

By setting  the horizontal value in the crosstab to month and the vertical to typeOfIncident you can get the following resut:

Incident                 Jan    Feb   March   April

A                           4        5           4           3

B                           10      3           12         5

C                           12       3           34        2

Total                     26      11          40        10

There is a lot more that you can do with crosstabs so try it out. They are a very powerful tool to use in your reports.

I hope this is somewhat clear.

Magnus

 

 



Post Edited by phantastes at 05/13/2009 17:15



Post Edited by phantastes at 05/13/2009 17:16
Link to comment
Share on other sites

Well if you have managed to create a report with static columns you will have set a number of Fields, right?

Now, create a crosstab object (start with putting the crosstab in the summary band). Then set the Fields you want to use in the crosstab. Let's say you have a list of the objects I mentioned above where each object has two parameters:

String month

String typeOfIncident

Now by setting these as Fields in iReport and using these fields in the crosstab you will get a dynamic number of columns based on the number of different months you have in your data.

I hope this helps somewhat.

Magnus

Link to comment
Share on other sites

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