Creating and Designing Report using iReport - Part 2
page 2 of 4
by Anuva Das
Feedback
Average Rating: 
Views (Total / Last 10 Days): 38611/ 50

Subreport

A Subreport (a report within a report) is an important feature of report generating tool. In some situations you might need more than one query to retrieve data from database, and then you can use the subreport feature of iReport. A report can contain more than one subreport. Each report, including a parent report and a child report, has its own SQL query to retrieve data from database.

Suppose you want to display the sales order details of each salesman. For that, first you have to create the parent report that displays all the salesmen. Now create the subreport that displays the order details of each salesman. To create subreport select “Edit-> Insert Element    ->  subreport” or click the “subreport” icons. It will open the following dialog.

Figure 1

Click the next button and write the query in the “SQL query” text box.

Figure 2

Now click the next button. Select the required fields to display in your subreport.

Figure 3

Continue the subreport generating process by clicking the next button. It will open the following dialog, having different layouts to display the subreport. Choose a suitable template from the above dialog for your report and click the next button.

Figure 4

In the following “Subreport expression” dialog, if you choose the first option then you have to specify the path of your subreport’s jasper file in the “SUBREPORT_DIR” parameter.

Figure 5

Now click the finish button to get a subreport table that displays your subreport.

Create a parameter (for example: salesmanId) in the subreport. Now open the properties by right clicking on the subreport icons. Click the subreport(Other) tab as shown in the following dialog.

Figure 6

To add a parameter click the Add button and fill up the parameter name and default value expression field in the “Add/modify parameter” dialog as shown in the following dialog.

Figure 7

Now change the subreport query to display the order details of each salesman by passing their “salesId” as a parameter to the subreport. The following query is used for this.

Listing 1

Select * from order_details where salesId = $P{salesmanId}

When it is run it generates a report like this:

Figure 8


View Entire Article

User Comments

Title: 2012 NFL jerseys   
Name: NIKE NFL jerseys
Date: 2012-05-20 11:37:56 PM
Comment:
[/pre]Cheap NFL,NBA,MLB,NHL
[url=http://www.jersey2shop.com/]Jerseys From China[/url]
[url=http://www.jersey2shop.com/]2012 nike nfl Jerseys[/url]
[url=http://www.jersey2shop.com/]cheap China Jerseys[/url]
[url=http://www.jersey2shop.com/]Sports Jerseys China[/url]
[url=http://www.jersey2shop.com/NFL-Jerseys-c68/]NFL Jerseys China[/url]
[url=http://www.jersey2shop.com/NBA-Jerseys-c77/]NBA Jerseys China[/url]
NHL Jerseys China
[url=http://www.jersey2shop.com/MLB-Jerseys-c94/]MLB Jerseys China[/url]NFL jerseys For Sale online.All Our Jerseys Are Sewn On and Directly From Chinese Jerseys Factory
[/pre]
[pre]We Are Professional China jerseys Wholesaler
[url=http://www.cheapjersey2store.com/]Wholesale cheap jerseys[/url]Cheap mlb jerseys
[url= http://www.cheapjersey2store.com/]2012 mlb all atar jerseys[/url]
[url= http://www.cheapjersey2store.com/ [/url]Cheap China Wholesael[/url]
[url= http://www.cheapjersey2store.com/]Wholesale jerseys From China[/url]
[url=http://www.cheapjersey2store.com/]2012 nike nfl Jerseys[/url]Free Shipping,Cheap Price,7 Days Deliver
[/pre]
[/pre]
We are professional jerseys manufacturer from china,wholesal
sports [url= http://www.cheapjersey2store.com/]Jerseys From China[/url]
[url=http://www.cheapjersey2store.com/NFL-Jerseys-c68]NFL jerseys China[/url]
[url=http://www.cheapjersey2store.com/NHL-Jerseys-c96/]NHL Jerseys China[/url]
[url=http://www.cheapjersey2store.com/NBA-Jerseys-c77/]NBA Jerseys China[/url]
[url=http://www.cheapjersey2store.com/MLB-Jerseys-c94/]MLB Jerseys China[/url]
[url= http://www.cheapjersey2store.com/]China Jerseys[/url],Free Shipping
[/pre]
[/pre]
We are professional jerseys manufacturer from china,wholesal
sports [url= http://www.jerseycaptain.com/]cheap jerseys sale online [/url]
[url= http://www.jerseycaptain.com/]2012 nike nfl Jerseys[/url]
[url=http://www.jerseycaptain.com/NFL-Jerseys-c68]cheap NFL jerseys China[/url]
[url=http://www.jerseycaptain.com/NHL-Jerseys-c96/]NHL Jerseys C
Title: Image   
Name: Sunil
Date: 2012-01-24 9:40:07 AM
Comment:
Hi, Unable to see images above which is making it hard to understand. Can anyone help me. Im trying to pass a field value from Main report to subreport.
Title: Useful   
Name: Rose
Date: 2010-12-30 1:47:02 AM
Comment:
pls help me to do it
Title: useful   
Name: Rose
Date: 2010-12-30 1:45:52 AM
Comment:
Hi...i used the same steps to do it.. but while doing subreports it showing warning msg...i single report is viewed
Title: Overlap   
Name: Aibek
Date: 2010-04-15 3:22:23 AM
Comment:
Hi. One asked this question before but i cant see the answers. So i am asking again. How about overlap say between 2000 and 2003 or something like this.
Title: mr   
Name: Joe
Date: 2010-03-15 2:34:48 PM
Comment:
what version of iReport supports crosstab? I'm using 3.5.2 and it doesnt' look like this at all!
Title: Multiple subreports   
Name: srikuba
Date: 2010-03-08 9:22:33 AM
Comment:
I have multiple subreports on my master report. Each of the subreport may or may not return results. How do i position the subreport on my master. If there are many columns, values are getting overlapped.
Title: overlap   
Name: jessica
Date: 2010-02-23 2:17:48 AM
Comment:
how about overlap data? for example from 24/01/2010 till 28/02/2010???
Title: Want to use Main report's parameter in subreport   
Name: Jaywant Patil
Date: 2009-07-15 3:01:05 AM
Comment:
I have one parameter in main report "Event_Code" which I want to pass to my subreport. Could you please help me out that how to do this ?
Please drop me an email to -

jaywant.patil@kpitcummins.com

I Desperately seek your help.
Title: crosstab   
Name: sonam
Date: 2009-06-24 4:46:15 AM
Comment:
hi.i hav succesfully made the crosstab,but its giving an error of "cannot cast from int to string".pls help
Title: How to display the 1st row value in 2nd row?   
Name: Saran
Date: 2009-04-24 9:10:54 AM
Comment:
For example:
Dept Location Ename Esal
---- -------- ----- ----
10 US AAA 100
10 US BBB 110
10 IND CCC 105
10 UK RRR 120
here dept 10 is repeating continuously.
how to disply like this?
It will be very greatful if helped me.
please send you valuable words to vsssaran@gmail.com
Title: Font   
Name: Anurag
Date: 2009-04-13 8:34:10 AM
Comment:
Hi How i use Hindi Fonts in Jasper iReport,Please help me.
Title: Sub report is not accepting the parameter from main report   
Name: Anjaneya
Date: 2009-04-01 5:54:35 AM
Comment:
hi really it is useful ... I followed the same step as u mentioned but sub report is not taking parameter from main report ony,,,,,,,, Please help me out
Title: query problem   
Name: Minesh
Date: 2009-03-26 5:53:55 AM
Comment:
hi i am using a sql query having case command in it to generate the output in the ireport..but the ireport dont through any error nor does it give any output..
Title: Query Problem   
Name: Raj
Date: 2009-03-24 5:49:48 AM
Comment:
How i handle more then one or two Query in the iReport tool i m using ireport-3.0.0 version. Please help me
Title: error in cross tab   
Name: saran
Date: 2009-02-11 4:23:06 AM
Comment:
while using the above procedure in cross tab .I got the error Not such enough space or view only the blank page .I do known the reason .please help me.
Title: Crosstab   
Name: Ananda
Date: 2009-02-10 3:12:47 AM
Comment:
Hi i am new to ireports. Howe to create crosstab using ireports tool.I am using ireport-3.0.0 version.I didn't seen any menu option summary in this tool.
Please help me.
Title: How we give the Title to column which are selected as row group   
Name: Jayraj
Date: 2009-02-02 1:30:22 AM
Comment:
How we give the Title to column which are selected as row group. can we do this?
Title: making subreport   
Name: nathan
Date: 2008-12-31 2:20:55 AM
Comment:
\
\
\
Title: crosstab   
Name: Stavan
Date: 2008-12-23 1:49:46 AM
Comment:
I am using i-report 2.0.2 so i am not getting option for Available subdataset. so not able to create crosstab.
Title: Please help   
Name: ascholl
Date: 2008-12-08 6:47:02 PM
Comment:
I created a subreport just like above. Everything compiles just fine, but when I run the report I get a NullPointerException. Any body have any ideas what might be missing or going on?

Thank You
Title: Thank you   
Name: Vijayan
Date: 2008-11-17 1:46:46 AM
Comment:
It is nice Keep it
Title: HELP please!!!   
Name: Rosa
Date: 2008-11-14 5:53:51 AM
Comment:
Hi i am an italian student and i need your help.
I am working to iReport and i want to illustrate in a table a question, the answer to this question and the number of man and the number of women how answered to the question.
I can't do this..please help me..it's important!!!
Title: Overlapping subreports resolution   
Name: Verocs
Date: 2008-10-29 4:59:51 AM
Comment:
Use Position-Type = FLOAT instead of FixRelativeToTop (=standard) to all the SubReports.
Title: Two Subreports   
Name: Emmanuel
Date: 2008-10-24 12:30:28 PM
Comment:
I am trying to create two subreports, one below the other. The problem is that when the upper subreport has a lot of rows, they overlap with the second report.

What can I do so that they don't overlap??? (Moving them separately is not an option since I want them together)
Title: doubt in crossta with group   
Name: kalpana
Date: 2008-07-01 7:15:06 AM
Comment:
i am tring to create the Crosstab with group , i am not able to create the summation for the grouped columns . pl guide me to design the report using i-reports.
thanks in advance
Title: Cross tab report   
Name: Navin
Date: 2008-06-16 6:45:45 AM
Comment:
I generated the cross tab report as per the steps, but have got blank output and the number of pages is 6, but each page is displaying nothing
Title: Page Display   
Name: Brendan
Date: 2008-06-09 9:16:34 AM
Comment:
Mr. Dilip,

I've fixed the display of the article. Thank you for mentioning this.
Title: Mr   
Name: Dilip
Date: 2008-06-09 7:51:04 AM
Comment:
The figure 10 in this url is missing.
Please provide the same asap
Title: Student SE   
Name: Shirhan
Date: 2008-05-28 9:41:37 AM
Comment:
Thanx once again! this article was the one I was looking for
I needed to print a Character certificate and had a problem of how to run a couple of queries so this will give the answer.

Once again you saved the day..... :-)
Title: Reply to Sandeep   
Name: Anuva
Date: 2007-08-11 11:47:28 AM
Comment:
Thanks.Still i'm not deciding.
Title: Nice work   
Name: Abhishek Kumar Singh
Date: 2007-08-11 6:54:01 AM
Comment:
Nice one.
Title: Hello   
Name: Sandeep Acharya
Date: 2007-08-10 9:49:28 AM
Comment:
Hello,
Nice to see the part 2. How many parts are yet to come??? Carry on.... I am counting the $s. Dont worry !!!

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-29 7:48:30 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search