### 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: Directly run a report
- Task 2: Run a parameter-based report
- Task 3: Run a report in Advanced mode

#### Task 1: Directly run a report

Direct running reports is to use the default format setting to view the report result. For page reports (for example, .cls) the default format is Page Report and they will run in Page Report Studio. For web reports (.wls) they will be opened in Web Report Studio by default.

If the reports are created on JReport Server, the default format is controlled by the Default Format for Viewing Report option in the Profile > Customize Server Preferences > General tab. When this option is set to Page Report or Applet, web reports will run in Web Report Studio by default.

If the reports are created using JReport Designer, the default format is controlled by the Default Format for Viewing Report property in the Report Inspector. If this property is set to <Server Setting>, the viewing format will be determined by the above setting on server.

Since a page report can contain multiple report tabs and these report tabs may have different default format settings, for example, report tab 1 is Page Report, tab 2 HTML and tab 3 Excel. In this case, there will be different direct running results according to which report tab is the last-time focused tab in the page report when the page report is saved at report design time. If it is report tab 1, all the tabs in the page report will be opened in Page Report Studio. If it is report tab 2 or 3, only tab 2 or 3 will be displayed in the specified format, and this applies to all the other formats except Page Report.

In this task, we will run a page report in the JinfonetGourmetJava folder as an example:

1. On the JReport Console page, go to the Public 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:

When you directly run a report, if the report contains parameters, you will be asked to specify the parameter values. See the next task for details.

#### Task 2: Run a parameter-based report

As you saw in the Creating a parameter-based report lesson, 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, 2015 and end date of June 1, 2015 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, 2015 8:00:00 AM to June 1, 2015 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: Run a report in Advanced mode

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`.