Skip to content

Jasper reports

julia-fms edited this page Jun 4, 2019 · 24 revisions

Here you will learn how to create Jasper report, include it into TG based application, produce PDF file, presented it for printing or email it as attachment.

Development of Jasper reports

Tools

To develop Jasper report for TG based projects Jaspersoft iReport Designer 4.7.1 should be used.

Templates

There are two types of reports:

  • simple report (all data is gathered from one or few entities and is simply presented)
  • more complex report; such report will contain one or more subreports (in this case data usually is presented as lines, with header and grid on the background)

Usually some sort of logo is presented in the report.

For example for TGPSA project Fielden's logo is stored at the following place: C:\work\tgpsa\tgpsa\tgpsa-web-server\src\main\resources\report_templates\images\logo.png

Two templates were created for TGPSA project: SimpleReportWithLogo.jrxml and ReportWithSubreport.jrxml to simplify process of developing reports. This templates are located at C:\work\tgpsa\tgpsa\tgpsa-web-server\src\main\resources\report_templates.

Report Styles

Three report styles [1] are introduced: reportStyle, reportBoldStyle and reportStyleArialBlack, which and used in both report and subreport.

Style reportStyleArialBlack is used for Report Title only.

Style reportBoldStyle is used for labeling of data. Word Description in report or column headers: Item No, Description, Amount in the subreport are using this style.

Style reportStyle is used for data fields.

Images

To include logo into the report the report parameter imagePath [2] is introduced to provide location for all images. This parameter is used in the Image Expression of the image object to specify what picture would be shown.

Representing of data

To represent data in the report new Fields [3] should be added, same is applicable to the subreports. Field should be of String type as all formatting would be done in TG. Names are case sensitive! Better to use same rules as in TG when naming variables here and make sure when you provide real data in TG you are using correct names.

Page Footer [4] contains some useful examples which are some times necessary when designing report: today's date/time and page numbering.

Development of subreport

Subreport usually contains two sections: Column Header and Details.

It should contain same Styles [1] for consistency with a main report. Please specify meaningful name into the Report name [2] and Page size [3] should be size of the area used in the report by subreport, this is especially important when you have few subreports! Job Pack for TG GAMS is good example when 5 subreports are presented one after another.

Subreport has to be compiled and as result the SimpleSubreport.jasper will be created. This jasper file has to be committed and released to the client. TG based application will be looking for this jasper file for subreport as only main report could be compiled in the run time.

To generate jasper file simply press Preview option in the design.

Including subreport into the main report

Two additional parameters are introduced: subreport and subreportData [1].

Object Subreport [2] is added into the Details section, also some rectangles to represent grid on the background.

Some properties of subreport object are very important.

For example Width and Height [2] should correspond to Page size of the subreport. Subreport Expression and Data Source Expression [2] should point to our additional parameters subreport and subreportData.

Clone this wiki locally