Skip to main content

Post 2: iReport: Creating your first "Hello World" report



Creating your first "Hello World" report
This recipe is a quick starter for someone who is using iReport for the first time. It shows you what views of your report the tool offers and what type of report components are available. This recipe also teaches you how to quickly make a simple "Hello World" report.

How to do it...
The following ten steps will show you how to make your first "Hello World" report.

1. Run iReport. Click on File and select New from the File menu. A New file dialog will appear, which contains several icons such as Report, Style, Chart Theme, and so on. Each icon represents a type of file you can create. The Report icon comes pre-selected, which means iReport allows you to create reports by default. as shown below:

 

2. Click on the Report icon on the top-left corner of the New file dialog. You will see a number of report templates available to start building your report.

 3. Select the Blank A4 report template and click the Open this Template button at the bottom. Blank A4 is the simplest of all templates and, therefore, is a good starting point to learn iReport and Following UI is appears: 


4. Next, you will be prompted to enter a filename for your report. Specify a name of your choice. I call my first report ASimpleBlankA4Report, as shown next. Click the Next button.


5. The Finish dialog will appear saying that you have successfully created your new report. 
 
Click on Finish to dismiss it.

6. iReport will open your blank report in its default view, which shows three tabs: Designer, XML, and Preview.



The Designer tab shows the various sections of your report such as Title, Page Header, Column Header, and so on, as shown in the above screenshot.

7. You will see a Palette of alphabetically arranged components (for example, a break, a chart, a static text, or a text field component) on the right of the main iReport window, as shown in the following screenshot.


Drag a Static Text component from the Palette and drop it into the Title section of your report. Similarly drag-and-drop another Static Text component into the Page Header section of your report. 

 

8. Click on the XML tab, which shows the JasperReports XML (JRXML) code that iReport authors in response to your designer actions in the Designer tab.
 
 

You will see that XML code for JasperReports changes every time you drag-and-drop a component from the palette into the designer view of your report. 

9. Double-click on the Static Text component of the Title section and type Hello World in it as shown:


10. Finally, switch to the Preview tab, which shows what your "Hello World" report will actually look like


 How it works...
 JasperReports has defined its own XML-based markup language called JasperReports XML, or JRXML for short. JRXML code contains all the information that is required to specify everything about your report. Therefore, designing a report using JasperReports means you have to perform the following steps:

1. Write JRXML code manually according to the requirements of your report.
2. Parse and compile the JRXML code to generate a JASPER file for your report.
3. Combine your JASPER files with application data to generate your report view.
This process is called filling.
4. Export your report view to a popular format such as PDF or XLS.

You normally need to write Java code to compile, fill, and export your JasperReport.

iReport is a JRXML authoring, compiling, filling, and exporting tool. This means that if you can author JRXML manually and write Java code to perform these tasks (compiling, filling, and exporting), you don't need iReport.

However, it is really troublesome trying to write JRXML manually. The graphical tools and components in iReport make it very easy and quick to author the JRXML according to the design requirements of your reports. iReport performs the following tasks for you to help you generate your report:

1. As a visual authoring tool, it helps you to generate JRXML by just dragging-and-dropping of components. It actually translates your visual actions to JRXML code.
2. It compiles the JRXML to generate a JASPER report file.
3. It also combines JASPER files with application data to generate a print preview for your screen and printer.
4. Then it may export this report preview to a popular format such as PDF or XLS.

iReport provides three integrated views to make your work easier: the designer view (where you design your report graphically), the preview view (where you can see the effects of your design), and the XML view (where you can view and edit the actual XML of a JRXML file).

In steps 8, 9, and 10 of this recipe, you played a little with the Designer, XML, and Preview tabs, respectively. You will need these tabs in almost every report you prepare using iReport.

The Designer tab is perhaps where you will work most of the time. It shows a window in which you will design your report by using different components such as static text, text field, and so on. These components are available in a palette of components on the right of your main iReport window.

In step 7 of this recipe, you played with the palette of components to quickly have an idea of how components are used in your report. The Palette window is split into two sections named Report Elements and Tools. The former contains several graphical components (for example, Static Text, Text Field, Frame, and so on), whereas the latter contains tools such as Current date and Page number.

Comments

Popular posts from this blog

TIME TABLE: VTU BE/B.Tech June/July 2016 Exam Time table Draft Layout

Semester-wise June-July 2016 Exam time table (Draft Layout) Are You Using updated Kwikstudy App?

Walkins Bangalore: 01st-Oct-2016

1. UTC Aerospace : GET – S&IS-Software Team hiring Electronics & CSE / IT Freshers ! Walkin on 1st OCT | BE/BTECH - 2015 & 2016 both batch can try Selection Process : Written Test Group Discussion Technical & HR Interviews How To Apply : It is a walk-in drive for 2016 batch eligible freshers on 1 Oct 2016 at Bangalore location. Interested and eligible candidates can walk-in to the following venue on 1 Oct 2016 Date of Drive : 01 Oct 2016 Reporting Time : 8:00 AM to 11:30 AM Venue : UTC Aerospace Systems – Site 1, Sy. Nos. 14/1 & 15/1, Maruthi Industrial State, Phase 2, Hoody Village, Whitefield Road, K R Puram Hobli, Bangalore – 560048 ______________________________________ 2. HP : Software Eng/ Software Tester (Call based ,less chance of getting entry , try at your own risk) Event Date : 1-October-2016 Event Time : 8 : 00 am Job Location : Bangalore / Chennai Job Description: Software Engineer /

How to get VTU Provisional Degree Certificate (PDC) ?

Here is the procedure to get the Provisional Degree Certificate from the VTU by passed out candidates. You can get the certificate through post by sending the required documents to VTU. Documents and things required: 1. Provisional Degree Certificate (PDC) application form 2. DD of specified fees amount or print copy of receipt if you paid the fees online 3. A letter to the VTU registrar 4. A4 size envelope Step 1: Fill the PDC application You can download the PDC application form from the VTU website. Click below link for application download. PDC application form download     After downloading the application take a print of it and properly fill the form. Step 2: Make a DD of specified amount as the fees of PDC: Go to the bank and make the DD of prescribed fee amount for the PDC. The fee amount is specified in the above link from where you downloaded the application. Make the DD in favor of " Finance Officer, VTU Belgaum ".   Wr