Skip to content
Lidia edited this page Jun 22, 2020 · 4 revisions

Quick guide: How to create a jaspersoft report

In this guide, we briefly explain how to create a report in Jaspersoft Studio based on the example of dashboard reports templates.

Jaspersoft Studio layout

Once you have downloaded and installed Jaspersoft Studio editor, let's take a look on the most essential parts, thats are listed below with a brief description of each.

jasper_studio_layout

  1. Project Explorer: Repository of folders where files are saved, its can be reports, data sources, images, etc.
  2. Outline: A summary of all items in the selected report.
  3. Design tab: Graphic view of the organization of the report with its elements.
  4. Source tab: Report code in jsxml.
  5. Preview tab: Window to preview the final result of the report with the data.
  6. Palette: Selector of items available for inclusion in the report, such as text, images, tables, graphs, etc.
  7. Properties: Section to modify the properties of the elements that make up the report, such as size, position, data source, etc.

Creating a report template

The specific steps for creating reports in both possible PDF and PPT formats are detailed below.

In both cases, first the base report will be created which contains only a single metric / quality factor / strategic indicator, then the global report is created, which will take the base report and fill it in repeatedly until you have all metrics / quality factors / strategic indicators.

Step 1

You must create a new data adapter (New Data Adapter button) to read the information provided by the dashboard and select that the source will be a JSON File, because the dashboard RESTFul services return data in this format. Finally, you need to specify the URL as shown below, with Options button necessary URL Parameters are specified.

metrics_data_adapter

Step 2

With the data source already defined, the next step is to create a new base report using New JasperReport button, where we will define the size (Blank A4 for PDF or Blank A4 Landscape for PPT), its data source (the adapter created in the previous step) and we will select the JSON fields that interest us for the report, such as the name, description, or rationale for each metric in Dataset and Query editor dialog.

Step 3

The next step is to graphically design the content of the report, adding titles, fields read from JSON, etc. In this case, we are interested in showing the name, description, and value of each metric, along with the reason why it gives this number.

  • When a text is specified with $F{field} means that the value is taken of the specific field of the data source, for exemple $F{name}.
  • When a text is specified with $P{field} it means that the value is taken from parameter field that must be defined or passed previouslly.

Note: In the gauge graph, used to display the value dynamically, the categories are defined manually (category ranges and colours) as default ones (Property tab >> Chart Plot >> Meter Intervals). They are not read automatically from the dashboard provided by the dashboard because is not possible to define this property in the chart dinamically.

If the report is added as a subreport, it is important to specify its data source, which will be each subsection of the general JSON that was created in the first step, as follows: ((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("metrics").

Step 4

Jaspersoft Studio has a feature called "Report Books", which allows you to add cover, index and back cover to reports.

New Report Book will be created to make the general metrics report and the base report created earlier will be added to the Content section.

metrics_report_book

factors_report_book

Step 5

Finally, just change the cover and index. In order for the index to automatically show where each factor is, a bookmark will be added to the base factor report below the name field.