Lesson 3: Running reports

This lesson describes how to run reports from JReport Console. This lesson represents one way that end users could access and run published reports. Reports that are embedded in a Java application would not be accessed from JReport Console, but instead from the Java application. The interaction with the report itself however would be the same as described here.

The reports you view in this lesson are in the JinfonetGourmetJava folder, which is the folder you published them to in Lesson 2 > Task 1 of this track.

Task 1: Run a page report in Page Report Studio

To run a page report in Page Report Studio is to use dynamic HTML to allow end users to interact with the report and change what is displayed. JReport provides a set of built-in commands that take advantage of this functionality to provide a powerful way to interactive report such as refreshing the data (running the underlying queries), changing the sort order of the data on the report, or filtering the data so that only a subset of records are displayed.

The Page Report Studio interface benefits a lot. Each end user can customize his own report to his favorite. The report does not have to be redesigned or even re-run.

The report template and future runs of the report template are not affected.

  1. On the JReport Console page, go to the My Reports > JinfonetGourmetJava folder.
  2. Click the ShipmentDetailsbyCustomer.cls link to run the report.

    A separate web browser window opens, with the report result for the ShipmentDetails report tab in the page report:

  3. Click the Interactive View link on the toolbar to locate the full toolbar commands.

    Before we interact with the report to change how the data displays, review some of the basic and useful toolbar commands:

    The navigational commands: first page, previous page, next page and last page.

    The current page and total number of pages.

    Commands for analyzing reports.

  4. On the toolbar, click the Sort button .

    This allows you to sort the results using any of the field values. The field values are automatically provided based on the DBField names but you can also reset these names to any that you want to use when creating the report in JReport Designer. For details, see Customizing the field display names in the JReport Designer User's Guide.

  5. In the Sort dialog, select SHIPPING COST from the field drop-down list, then click OK.

    The report appears with records in each group sorted by the SHIPPING COST values. By default, the sort order is set to Ascend.

  6. On the toolbar, click the Filter button .
  7. In the Filter dialog, set the filter condition to SHIP VIA = United Packing. Click OK to apply the filter.

    The report now displays records shipped via United Packing only in each group, sorted by the SHIPPING COST value.

    It is easy and convenient for an end user who needs this specific information to view this report. The report format is quickly restructured, but the report template is not changed. It will not affect other people to run this report.

  8. Click the close button of the browser window to close the report viewing window.

On the Page Report Studio menu, there is an important command that we will not step through in this lesson: the Refresh command. Refresh accesses the DBMS and re-selects all of the data. Refresh is useful when data is changing dynamically and you want to see the latest information from the DBMS.

Task 2: Run a parameter-based report

As you saw in Lesson 8 of Track 2, parameter-driven reports are another way to have a dynamic report. They allow the end users to specify the data that they want to see before the query is issued to the database. By only selecting the data that the report needs, the query is more efficient.

When a parameter-based report is run, JReport Server automatically generates an HTML page to prompt the user for the expected values. Default values, if included in the report template definition, are also displayed.

To run the parameter-based report:

  1. In the JinfonetGourmetJava folder, click the OrderListbyDate_Parameter.cls link.

    A new web browser window opens for you to enter the parameter values. The report template includes start date of May 1, 2010 and end date of June 1, 2010 as default. You can click Submit button to admit these defaults, or you can type new values to view the report.

  2. The requested report is displayed showing only order details from May 1, 2010 8:00:00 AM to June 1, 2010 8:00:00 AM. The Page Report Studio toolbar is included, and the toolbar commands can again be used as they were in the previous task.

Task 3: Save a report in a different format

The Advanced Run command allows you to specify additional properties when running a report, for example you can specify a different report format instead of the default one. Options available include Applet, HTML, PDF, Text, Excel, Postscript, Rich Text Format (RTF), XML and Page Report. In this lesson we will run the report as PDF format.

  1. In the JinfonetGourmetJava folder, click in the CustomerContactCard.cls row, right-click in the row and then select Advanced Run from the shortcut menu.
  2. Click the Format tab and select PDF from the Select Format drop-down list, as shown below:

    For this lesson, the additional options in the Advanced Run page are not used. However these options can be quite useful in real reporting scenarios. For example, you can specify database credentials under which the query should execute, or apply a style group so that the report has a different look and feel.

  3. Click the Finish button.

    The report is displayed as a PDF file in your web browser. You can now browse the report, print it, e-mail it to a co-worker, or save it to your local disk using the Adobe Reader commands.

    The PDF file is assigned a unique name and saved in \temp; by default is C:\JReport\Server.

Task 4: Navigate and search report

In this task, we return to the Page Report Studio toolbar and explore two more of its powerful commands: TOC Browser and Search.

  1. In the JinfonetGourmetJava folder, click the EmployeeInformation.cls link.

    The report tab EmloyeeDetails in the page report displays in a new web browser window.

  2. Click the Interactive View link on the toolbar to locate the full toolbar commands.
  3. Click Menu > View > TOC Browser to display the following TOC Browser panel:

    From the TOC Browser panel you can simply click on an entry to scroll the report display to that section.

    JReport Server also supports full text search of reports.

  4. On the toolbar, click the Search button .
  5. In the Search dialog, choose the field on which you'd like to search from the Search Field drop-down list, specify the value range and then enter any specific field values. For example, to search for the hire date 7/23/2003, enter the values as follows:

  6. Click Search to start the search.

    The report display moves to the correct location.

Lesson 3 summary

This lesson described the ways in which published reports can be run, including how the Page Report Studio toolbar allows an end user to sort and filter data in the report. This lesson also showed a parameter-based report which allows an end user to choose the data displayed in the report. Lastly, this lesson showed how to export a report to PDF, search a report, and use the TOC Browser to navigate a report.