| This section describes functionality that can be restricted by the software license for JasperReports Server. If you don’t see some of the options described in this section, your license may prohibit you from using them. To find out what you're licensed to use, or to upgrade your license, contact Jaspersoft. |
The interactive Report Viewer lets you and your users interact with saved reports to visualize the data in different ways. Report users can select a report template, format tables and charts, filter reports, and highlight table values using conditional formatting.
Working with Report Templates
You can add custom report templates to your JasperReports Server instance by uploading a JRXML file to a Templates directory. In addition to font and color choice, reports templates can contain images such as logos. In a template, the absolute path of image is in the repository and cannot be overwritten. Users can apply your template by selecting Custom Report Template when they create a report from an Ad Hoc View.
Creating a Report Template
When creating a template it is easiest to start with an existing template in JasperReports Server and change the values for the properties you want (colors, fonts, logos, etc.) in Jaspersoft Studio. Then, publish the new template to the server. This example shows how to change the font for a chart title.
To create a template:
| 1. | From Jaspersoft Studio, connect to JasperReports Server as superuser . |
| 2. | In the Repository pane, navigate to the Public/Templates directory. |
|
Accessing the Templates directory from Jaspersoft Studio |
| 3. | Right-click A4 Landscape in and choose Open in Editor. |
|
Default A4 landscape template |
The document will look empty, but if you click the Sourcetab, you see that attributes are set at the JRXML level. Note the attributes for ChartTitle:
<style name="ChartTitle" forecolor="#000000" fontName="DejaVu Sans" fontSize="12" isBold="true"/>
You can edit styles directly on the Sourcetab if you choose.
| 4. | Click the Design tab, and in the Outline view, click the arrow next to Styles. |
|
Style tab in Properties View |
The styles open in the Properties tab.
| 6. | Make the following changes: |
| a. | Font: Century Gothic, 14 pt, bold, italic. |
| b. | Change the forecolor to red (Click Appearance for that change.) |
| You can link to an image in your template by uploading the image to the repository and then dragging it into the appropriate band in the template. The template uses the absolute path to the image in the repository and the image cannot be changed or overwritten. |
To save and publish a template:
| 1. | Save the template with a new name. |
| 2. | A pop-up will ask if you want to publish the report to JasperReports Server. Click Yes. |
|
Report Publishing wizard |
The Report Publishing wizard appears.
| 3. | Select the folder in which you want to store your template, and click Next. |
A pop-up will appear letting you know that the template has been published successfully.
Report Template Styles
When you view a report template in Jaspersoft Studio, you see it includes styles, which inherit attributes from other styles or from a default value. When you open one of the default templates in Jaspersoft Studio, you can see the available styles listed in the Outline view. In JasperReports Server 5.5, the Table and Crosstab styles are implemented, but the Chart styles are not, with the exception of the ChartTitle.
The Inheritance tab in the Properties view shows you which styles are inherited and from where. That makes it easy if you want to change a style at a higher level, or have an attribute inherited by more styles.
|
Inheritance tab |
Working with Conditional Text
This section shows how to use multiple conditions in a table to create a stoplight format based on ranges. To set up this format, you need to use the inheritance feature of conditional formatting. For colored backgrounds, this specifies that when a table cell satisfies multiple conditions, the condition that appears highest in the list of conditions is applied.
To create the Ad Hoc table for use in the example:
| 1. | Select Create > Ad Hoc View from the menu. The Data Chooser wizard opens. |
| 2. | Click Domains, select SuperMart Domain, and click Choose Data. The Data Chooser opens to the Select Fields page. |
| 3. | In the Source panel, double-click Sales to move it to the Selected Fields panel. |
| 4. | Click Table. The Ad Hoc Editor is displayed with the selected fields. |
| 5. | Double-click the following fields and measures to add them to the Columns area: Product Name, Recyclable Packaging, Store Sales. The Ad Hoc view appears as shown in the following figure. |
Ad Hoc View for Conditional Text |
|
| 6. | Hover over |
| 7. | Fill in the required fields as follows: |
| a. | Data View Name: Conditional Text Example View |
| b. | Data View Description: Created in Ultimate Guide |
| c. | Report Name: Conditional Text Example Report |
| d. | Report Description: Created in Ultimate Guide |
| 8. | For Save Location, click Browse, select Organization > Reports > Samples, and click OK. |
| 9. | Click Save. A message confirms that the view was saved. |
To open the report in the viewer:
| 1. | Select View > Repository. |
| 2. | Navigate to Organization > Reports > Samples and click Conditional Text Example Report. The report opens in the interactive report viewer. |
To create “stop light” conditional formatting on a numeric column:
| 1. | Click the Store Sales column. The column is highlighted and the column formatting icons appear at the top of the column. |
| 2. | Move your mouse over |
| 3. | Click the Conditional Formatting tab. The Conditional Formatting options appear. |
| 4. | Click Add to create a new condition, and fill in the fields as follows: |
| a. | Select Greater than from the Operator menu. |
| b. | Enter 8 in the Condition box. |
| c. | Click |
| 5. | Click Add to create a second condition, and fill in the fields as follows: |
| a. | Select Greater than from the Operator menu. |
| b. | Enter 3.5 in the Condition box. |
| c. | Click |
| 6. | Click Add to create a new condition, and fill in the fields as follows: |
| a. | Select Less than or equal to from the Operator menu. |
| b. | Enter 3.5 in the Condition box. |
| c. | Click |
Conditional Formatting for Numeric Values |
|
| 7. | Click OK. The dialog box closes and your choices are applied. The report appears as shown in the following figure: |
Report with Conditional Formatting |
|
Notice that numbers greater than 8 satisfy the first two conditions; the first condition they satisfy is the one that is applied.
Recommended Comments
There are no comments to display.