You can build a report in JReport in one of the following two ways:
In this lesson you will learn:
Before you continue, you may want to review the basic definitions and some of the terminology used to describe JReport and its components.
The simplest type of report is called the "standard report". Below is an example of a standard report with the title "Customer Sales Report". Detail customer records are grouped by Country and within each country by Region. The Sales from last year are totaled for each Region and for each country.
Customer Sales Report
| City | Customer Name | Phone Number | Annual Sales |
| Cupertino | The Island Coffee | (408) 777-0001 | $98,239.00 |
| Irvine | Cafe International | (714) 243-9548 | $51,958.00 |
| Los Gatos | International Coffee Hut | (650) 867-9879 | $81,349.00 |
| Palo Alto | Automatic Java Machines | (650) 239-4690 | $74,986.00 |
| San Francisco | Cafe San Francisco | (415) 288-9090 | $67,823.00 |
Annual Sales Totals: |
$374,355.00 | ||
| State: New York | |||
| City | Customer Name | Phone Number | Annual Sales |
| Dix Hill | The Ultimate Bean | (212) 938-4491 | $54,738.00 |
| New York City | Starmug Coffee | (212) 834-9082 | $101,001.00 |
| New York City | Absolute Java | (212) 946-3462 | $50,600.00 |
| Scarsdale | The Java King | (914) 657-9823 | $78,321.00 |
Annual Sales Totals: |
$284,660.00 |
Annual Sales Total in the USA: $659,015.00 |

Let's first look at the Data tab. Here you must choose the
objects you are interested in from the All Objects list and place them
into the Working Set list. For this example, open the
Connections item. Next click the Jinfonet data source and
select the Customer table. Click the
button to add all of the fields in the table to the Working Set.
You can also open the table and add individual fields one by one to the Working Set.



Note: Records in a report are usually organized into groups based on certain criteria. With the Group/Sort tab you can enter the criteria to define multi-level groups. You can also specify the ordering of groups and ordering of records within each group.
For this example, we will group the data by selecting Country and then by Region. The arrows beside the field names indicate the sorting sequence of the groups. You can choose from descending order (ex: c,b,a), ascending order (a,b,c) or specify a special ordering criteria (indicated by "S").

To generate
a total sales amount for each
Region
group, select Last Year's Sales, click the
to move it to the Summary
Fields. The Function drop down list allows you to select a
summary function like sums, counts, minimums, maximums, etc. We will select Sum
for this example to see a total of Last Year's Sales.
The Function is computed when the Break Field changes value at the end of a group. Clicking the Region field will cause a sum to be created for each Region group. Leave the Grand Total column checked so that we get a total sum of last year's sales in the country.


Now you are ready to finely tune your report and give it a professional look. Report Wizard provides you with a quick start but JReport provides a wealth of tools for you to adjust the report to your preference. Use the Report Inspector to change font, size, position, and other variable. Do not forget that you can also move items anywhere in the Design view. Try to insert labels and texts and place objects in headers/footers and details.
What is a Parameter?
Frequently you need to specify a
parameter when running a report. For example, you may want to input an order
date as an input parameter when running a report so that only orders on that date
will be displayed. Typically, parameters are used as part of the query
conditions (search criteria) so that only records satisfying that parameter will be
retrieved to become part of the report.




