Skip to main content

Post 3: iReport for Java


Datasets and Table component in Jasper Reports

Welcome to the Post 3. In previous articles we went through the Introduction of iReports and Building a Simple iReport . In this article, let us add some functionality to our report by adding a table and datasets .
Tables plays a very important role in every design , in iReports Tables are used to represent data in an efficient and usefull manner. Most of the time we need to iterate our dynamic data to display the output , in case of iReports this is done by Tables and Datasets .
Let’s take a brief look at how to use a Table Component to generate a simple tabular representation of data. The following are the basic steps we will take:
  1. Create a saperate Dataset so that we could iterate the data easily .
  2. Add a table component to detail band of the report , and set its  basic layout and structure.
  3. Put Dataset variables(Fields) in table to generate desired result.
  4. Preview the report to see the table functionality.
Creating a Dataset
To create a Dataset , right-click on your Report in Report Inspector and choose Add Dataset :




A setup window w’ll appear like this :


Provide a name to Dataset and let the first radio button selected for now , click next 



In Connections/Data Sourse select the  connection that is used to your main report . Enter an appropriate query that w’ll provide us data to use in table. Now click next : 
 
In left side of the screen designer w’ll show all the datafields that can be extracted from the query , add those fields to the right side that are going to be used in table. Now click next : 

Let this page empty as it for now , and click on Finish . Here we are done with Dataset , we can review and edit it from out Report Inspector, as shown in below image : 



Adding a table component to report.
Now we w’ll add a table on required position to do this go to Palatte section and select Table component :
Drop the Table component in Details Band , now a Table Wizard window w’ll pop up , like this :


Now we need to connect our Dataset to Table , just select appropriate Dataset from drop down list and click next : 

Now select Field that you want to use in your table , and click next :

Here we can select a db connection for our Table , let the very first radio button be selected for now , click next :



Here we can set layout and design for our table , click finish and we are done with it .After creating Table you w’ll get a Table View of Designer like this : 

Here we can add Headings and Data Fields to our table .In Main Reporst we can see an Table Icon like this , table position in the Report can be adjust from here 
 
No to see the result go to Preview and you w’ll get an table added to your report , like this
Here we are done with adding a table to our report .In next post we w'll cover How  to Create a sub report and pass parameters to it.

Comments

Popular posts from this blog

Index: JSF

Java Server Faces Basics Post 1: JSF : Introduction to JSF  Post 2: JSF:  configuration files  Post 3: JSF: Installation Post 4: JSF: Your first JSF project   Standard JSF Tags Post 1: JSF: textbox example Post 2: JSF: password example Post 3: JSF: textarea example JSF 2 GraphicImage Example Post 4: JSF: GraphicImage Example Post 101 : JSF : The valueChangeListener Attribute Example

Index: iReport

iReport for Java ------------------------------------------------------------ Titles and Headers ------------------------------------------------------------ Post 1: iReport : Downloading, installing, and running JasperReports and iReport Post 2: iReport : Creating your first "Hello World" report   Post 3: iReport : Understanding iReport Elements Post 4: iReport : Creating and sizing the title for your report Post 5: iReport: Inserting a company logo in the title of your report  Post 6: iReport : Installation of PostgreSQL Post 7: iReport : Creating a report from relational data Post 8: iReport : Using dynamic titles that can change during report processing. Post 9: iReport : Adding a simple header to your report Post 10: iReport : Setting margins for your report and aligning the report header relative to report margins  ------------------------------------------------------------ Body and Footer ---------------------------------------------------------...