IREPORT MANUAL PDF

adminComment(0)
    Contents:

iReport Designer, JasperReports Library, JasperReports Server, Jaspersoft This is version UGI of the iReport Ultimate Guide. Unexpected server response. More Information Less Information. Close. ritipulmama.ga v (build: 17df) Message: Unexpected server response () while. Jaspersoft, the Jaspersoft logo, Jaspersoft iReport Designer, JasperReports Library, This is version UGJ of the JasperReports Ultimate Guide.


Ireport Manual Pdf

Author:SHANTELLE DEMIEL
Language:English, Arabic, French
Country:El Salvador
Genre:Health & Fitness
Pages:607
Published (Last):02.11.2015
ISBN:600-8-61903-172-7
ePub File Size:28.73 MB
PDF File Size:10.59 MB
Distribution:Free* [*Registration needed]
Downloads:46935
Uploaded by: CORRIN

This is the iReport reference manual; it documents iReport version As iReport is work in progress, the manual gets updated frequently (if I have sufficent . iReport User Manual - Free ebook download as PDF File .pdf), Text File .txt) or read book online for free. Sample Ireport Ultimate Guide 3 PDF - Free download as PDF File .pdf), Text File .txt) or read online for free.

The jQuery library DataTables [32] is used to create table etc. Layout is mostly left up to if requested by the user. There is an option to create the browser, but users can explicitly add a line-break after hyperlinks within the columns of a table by providing a each item to force items to appear underneath each other.

This generates a hyperlink to the correspond- items on the page. Text is printed verbatim, although ing GeneCards entry for every item in the column in the a small number of HTML tags are allowed in order to table. Text files can also be spec- Content item: PDF files This is one of the simplest ified, and the contents of the file will be printed to the content items.

The user provides a PDF file from the screen verbatim. Galaxy history, which will be embedded in the page.

If the browser does not have the necessary plug-ins installed, Content item: images Many tools produce images as a download link for the file will be generated instead output, which can also be displayed by iReport. Users Figure 5. Given an archive of files, iReport can create a series of links to all files contained in the archive.

Link texts are the filenames without file extension. Content item: links Users can create links to web loca- a trio analysis generated from the Complete Genomics tions by specifying a URL and a link text.

Links to datasets [36] NGS platform to demonstrate its utility in represent- in the history can also be created here by specifying a ing these data in a user-defined format, which contains dataset and a link text. Several tools create archives of the provenance of the underlying analysis. In this example files as output for example a zip file containing the plots we use a trio of individuals sequenced in the International for each chromosome.

Links to all files contained in an HapMap Project [37,38], to demonstrate how to select archive can also be created, and will be named with the file protein affecting candidate variants based on a recessive names excluding file extension. Currently the supported genetic model.

All data in this example is freely avail- archive formats are zip, bz2, tar, gz and tar. An example able for download from the Complete Genomics website can be seen in Figure 6, where an archive with images was [39]. An option to create a link to an iReport is also the protocol used Figure 7B , one tab with circos plots present. This allows users to create a kind of electronic lab and an explanation of the family structure Figure 7D , and notebook, by creating an overview of all their samples and one tab with tables containing the candidate pathogenic linking to one or more iReports for each sample.

Accurate, reproducible and traceable reporting is an essentialrequirement to the evaluation of the genetic out- come from any assay [35], including those variations pre- Conclusions dicted from NGS analysis.

You are here

Since iReport is capable of iReport is a easy-to-use, flexible tool for generating including many formats, we have used the outcome from traceable, standardized reports which are easily shared Hiltemann et al.

Example iReport for Clinical Genetics. A Cover page with custom image. B First tab, explaining the protocol used. C Second tab, tables of candidate pathogenic variants, gene columns linking out to GeneCards.

D Fourth tab showing Circos images and family structure. Galaxy and may be shared with collaborators on the same psu. Additionally, data or results Operating system s : Unix-based Operating Systems generated externally can be uploaded into Galaxy and can Programming languages: Bash, Perl, Python also be used by iReport.

Any restrictions to use by non-academics: none The genetics report presented here represents the bare minimal reporting that is required to summarise the out- Examples: put for a genetic variation analysis.

We have also Availability and supporting data utilised iReport for more complex analysis workflows, The iReport tool, user manual published page , and such as summarising translational research and diagnostic example data and histories are available at the CTMM- applications for cancer and immunological research and TraIT Galaxy server [40]. SH and AS contributed to implementing iReport. SH, BMC Genomics Acknowledgements , This study was performed within the framework of the Center for Translational TraIT project grant 05T Bioinformatics , 30 10 — Genome functional genomics compendium with automated data mining and Biol , 11 8 :R Bioinformatics , 14 8 — Curr Protoc in Mol Biol Bioinformatics , 26 7 — Genome Res GigaScience , 3 1 Nature , adhoc] — Bioconductor: Open Source Software for Bioinformatics An entire handbook chapter is dedicated to datasources, where it is explained how they can be used in iReport and how it is possible to define custom datasources in the case that those supplied with JasperReports are not right for your requirements.

The JRDataSource allows to read a set of records which are organized in tables lines and columns. These couples are named parameters and they have to be preventively declared in the report. Through the fillManager it is possible to join a jasper file and a datasource in a JasperPrint object.

This object is a metaprint which can create a real print after having been exported in the desired format through appropriate classes which implement the JRExporter interface. JasperReports puts at your disposal different predefined exporters like those for creating pdf, xls, cvs, xml, html, etcfiles. Through the JRViewer class it is possible to view the print directly on the screen and to print it.

Compatibility between versions When a new version of JasperReports is distributed, usually some classes change. These modified classes typically define the report structure. So in order to avoid conflicts among reports that are compiled with libraries of different versions, JasperReports associates a SerialVersion in reality it is inherited from the JasperReport class with every compiled jasper file, which identifies the exact library version used for the compilation. If you execute a print loading a jasper file, which has a SerialVersion different from that one supported by the used library, an error will occur.

It may be similar to the following: JRBaseReport; local class incompatible: Error loading object from InputStream Caused by: However, the old report sources can be compiled with newer library versions than that with which the sources were first compiled with: The migration from a JasperReports version to a following one is substantially painless and it can quickly be executed thanks to the iReport plugin named massive compiler which allows one to carry out a massive compilation of all reports within a directory structure, keeping a safety copy of the already existing jasper files.

We will talk about the massive compiler in the chapter that is dedicated to the plugins. Expressions All of the formulas in JasperReports are defined through expressions. An expression is a java instruction which has an object as a result. Expression examples are the following: Non valid expression examples are the following: In particular the first and the second expressions are not valid because they are of a primitive type int in the first case and boolean in the second case.

The expression return type is determined by the context. For example if the expression is used to determine the moment when an element has to be printed, the return type will be Boolean. Similarly, if I writing the expression which underlines a numerical field, the return type will be an Integer or a Double.

Within the expression I can refer to the parameters, variables and fields, which are defined in the report using the syntax summarised in Table 3. Syntax Description. Fields, Variables and Parameters always represent objects they can assume the null value and their type is specified at the moment of their declaration.

After the 0. It is used for the localization of strings we will talk about them in the chapter dedicated to internationalisation. Often an expression can be insufficient for defining the return object. For example, if you want to print a number in Roman figures, or give back the name of the weekday in a particular data, it is possible to transfer the elaborations to an external class method, which is declared as static, as follows: This technique can be used for many aims, for example too extrapolate the text of a CLOB field, or to add a value into a HashMap parameter.

This operation cannot be executed by means of a simple expression. A simple program We finish this introductory chapter about JasperReports proposing an example of a simple program Listing 3. JREmptyDataSource is a kind of empty datasource. The test. JRPdfExporter ; exporter. Bands A report is defined by means of a type page. This is divided into different horizontal portions named bands.

When the report is joined with data to run the print, these sections are printed many times according to their nature and according to the rules which the report author has set up. For instance, the page header is repeated at the beginning of every page, while the detail band is repeated for every single elaborated record. The type page is divided into nine predefined bands to which new groups are added. In fact, iReport manages a heading band Group header and a recapitulation band Group footer for every group.

Figure 4. A band is always as wide as the usable page width right and left margins excluded. However, its height, even if it is established during the design phase, can vary during the print creation according to the contained elements; it can This typically occurs when bands contain subreports or text fields that have to adapt to the content vertically.

Generally, the height specified by the user should be considered the minimal height of the band. Not all bands can be reorganized dynamically according to the content, in particular the Column Footer, Page Footer and Last Page Footer. The sum of all band heights except for the background has to always be less than or equal to the page height minus the top and bottom margins.

Title This is the first visible band. It is created only once and is able to be printed on a separate page. With a little bit of astuteness, you can take advantage of this capability in order to simulate a page break using subreports we will see how a little bit later. As regards the admitted dimensions, it is not possible to exceed, during design time, the report page height top and bottom margins are included.

If the title is printed on a separate page, this band height is not included in the calculation of the total sum of all band heights, which has to be less than the page height, Page header This band allows one to define a page header. The height specified during the design phase, usually does not change during the creation process except for the insertion of vertically resizable components, such as textfields that contain long text and subreports.

The page header appears on all printed pages in the same position defined during the design phase. Title and Summary bands do not include the page header when printed on a separate page. Column header This band is printed at the beginning of each detail column. The column concept will be explained in a little while.

Usually, labels containing the column names of the tabular report are inserted in this band. Group header A report can contain zero or more group bands, which permit the collection of detail records in real groups. A group header is always accompanied by a group footer both can independently be visible or not.

Different properties are associated with a group. They determine its behaviour from the graphic point of view. It is possible to always force a group header on a new page or in a new column and to print this band on all pages if the bands below it overflow the single page as a page header, but a group level. It is possible to fix a minimum height required to print it: In all probability, most of the print elements will be put here. Group footer This band completes a group.

Usually it contains fields to view subtotals or separation graphic elements, such as lines, etc Column footer This band appears at the end of every column. Its dimensions are not adjustable not even if it contained resizable elements such as subreports or text fields with a variable number of text lines.

Page footer This is the page footer. It appears on every page where there is a page header. Like the column footer, it is not resizable. Last Page footer If you want to make the last page footer different from the other page footers, it is possible to use this special band. If the band height is 0, it is completely ignored and the layout established for the common page will be used also for the last page.

It first appeared in the 0. Summary In other systems this section is named Report footer. It allows one to insert fields concerning total calculations, means, or whatever you want to insert at the end of the report. Background This band appeared for the first time in the 0.

It was introduced after insistent requests from many users in order to be able to create watermarks and similar effects such as a frame around the whole page. It can have a maximum height equal to the page height.

Report properties Now that we have seen the individual parts that comprise a report, we will proceed to creating a new one. Press the button or select New Document from the File menu: Here you will fill in the report properties Fig.

This window is recallable anytime by selecting Report properties from the View menu. The first property is the report name. It is a logical name, independent from the source file name, and is used only by the JasperReports library e. The page dimensions are probably the reports most important properties. A list of standard measures is proposed. The unit of measurement used by iReport and JasperReports is the pixel which has a resolution of 75 dpi, dots per inch.

However, it is possible to specify the report dimensions using units of measurement that more common, such as centimeters, inches or millimeters. Table 4. Just because the dimensions management is based on pixels, some rough half adjusts can take place viewing the same data using different units of measurement.

Page type Dimensions in pixel. By modifying width and height, it is possible to create a report of whatever size you like. The page orientation option, landscape or portrait, in reality is not meaningful, because the page dimensions are characterized by width and height, independently from the sheet orientation.

However, this property can be used by certain report exporters. The page margin dimensions are set by means of the four entries on the Page Margin tab. Columns As we have seen, a report is divided into horizontal sections: The page, which composes the report, presents portions which are independent from the data such as the title section, or the page footers , and other sections which are printed only if the number of data record to print is different from zero such as the group headers and the detail.

These last portions can be divided into vertical columns in order to take advantage of the available space on the page. In this context the concept of column can be easily confused with that of field.

In fact, the column does not concern the record fields, but it does concern the detail band. This means that if one has a record with ten fields and a table view is desired, ten columns are not needed. However, the elements will have to be placed correctly to have a table effect.

Ten columns will result when long record lists that are horizontally very narrow are printed. In the following figures two examples are shown. The first shows how to set up the values for a single column report on an A4 sheet. The number of columns is 1 and its width is equal to the entire page, except for the margins. The space between columns is not meaningful, in this case, so it is zero.

As you can see in Figure 4. If multiple columns are used, the report look would be better. In this case, in the Columns, as in columns number, field we have inserted 2. If you want to increase the space between the columns, just increase the value of the Spacing field. As we see in Figure 4. Multiple columns are commonly used for prints of very long lists for example the phone book. Functionally, it is important to remember that when you have more than one column the width of the detail band and of linked bands is reduced to the width of the column.

The sum of the margins, column widths and every space between columns, has to be less than or equal to the page width. If this condition is not verified the compilation can result in error. In Figures 4. The parts which are not utilizable, such as margins and columns following the first one which have to be considered like the continuation of this one are highlighted in grey. Advanced options Up to now we have seen only basic characteristics concerning the layout.

Now we will see some advanced options. Some of them will be examined thoroughly and explained in every detail in the following chapters, and some of them will be fully understood and used in a useful way only after having acquired familiarity with the use of JasperReports. Scriptlet A scriptlet is a java class whose methods are executed according to specific events during report creation, like the beginning of a new page, the end of a group, etc.

For An entire chapter of this handbook is dedicated to the scriptlet. In the scriptlet tab Figure 4. If you do not want to use a scriptlet, set the Dont use scriptlet class More In the More In the More Title on a new page option The Title on a new page option specifies that the title band is to be printed on a new page, which forces a page break at the end of the title band.

Figures 4. In the editor the print is always the same Figure 4. As one can see, no one other band is printed on the title page, not even the page header or page footer. However, this page is still counted in the total pages numeration. Summary on a new page option This option is utterly similar to the previous option except for the summary band that is printed as the last page.

Now, if it is required to print this band on a new page, the new page will only contain the summary band. Floating column footer option This option allows one to force the print of the column footer band immediately after the last detail band or group footer and not at the end of the column. This option is used, for example, when you want to create tables using the report elements see the JasperReports tables.

Print order The Print order determines how the print data is organized on the page when using multiple columns.

The default print order is Vertical, that is, the records are printed one after the other passing to a new column only when the previous column has reached the end of the page like what happens in the newspaper or the phone book. Horizontal print order prints the different records horizontally across the page occupying all of the available columns before passing to a new line. Refer to Figures 4. The prints in these two figures should clarify the concept.

As one can see, the names are printed in alphabetical order. In Figure 4. Print without data when no data When to the print number is supplied an empty data set or the SQL query associated to the report gives back no records , an empty file is created or a stream of zero byte length is given back. This default behaviour can be modified by specifying what to do in the case of absence of data that is when no data. NoPages Default; the final result is a empty buffer.

BlankPage It gives back an empty page AllSectionsNoDetails It gives back a page constituted by all the bands except for the detail detail band Table 4. Resource Bundle Base name The Resource Bundle base name is a parameter used when you want to internationalise a report. The Resource Bundle is the set of files that contain the translated text of the labels, sentences and expressions used within a report in each defined language.

A language corresponds to a specific file. The base name represents the prefix through which you can find the file with the correct translation. We will explain internationalisation in greater detail in chapter However, if you want to use some characters which need particular encoding in the XML, it is necessary to specify the correct charset. The UTF-8 manages all accented letters and the euro.

Other common charsets are listed in the encoding combobox ISO is widely used in Europe. In this chapter we will explain the main objects which can be inserted into a report and which are their characteristics.

With element we mean graphic object, such as a text or a rectangle. Unlike what happens with word processor, in iReport the concept of paragraph, table or page break does not exist; everything is created by means of elements which can contain text, create tables when they are opportunely aligned, and so on. This approach is that which is adopted by the most of report tools.

The basic elements offered by the JasperReports library are seven: In addition to them, iReport provides two special elements based on the Image element: Every kind of elements have some common properties such as the height, the width, the position, the band to which they belong, etc and other specific properties of the element for example the font or, in the case of a rectangle, the thickness of the border. It is possible to group the elements in two macrocategories: The subreports represent a separate kind of element and because of the complexity of their use, we will deal with them in a separate chapter.

The elements are inserted into bands. In particular every element is associated indissolubly to a band. If the element is not completely contained into the band Insert and select elements in the report In order to add an element to a report, select one of the tools present on the toolbar figure 5. Ellipse tool Subreport tool. The arrow tool is used for doing all the most important operations on the elements selecting, etc and its activation switch off an other active tool.

When you have chosen the element to insert, press the mouse left button on the band where you want to insert the element and draw a rectangle dragging the mouse downward on the right. By leaving the mouse button, a new element will be created and it will be selected automatically.

The new element will also appear in the elements browser on the right of iReport desktop. This window is organized in severl tabs. The Common tab contains the properties commons to every kind of element, the other tabs are specific of each kind of element. It is possible to select more elements at the same time by using the arrow tool and drawing a rectangle which will contain, even only in part, the elements to select.

The selection area is highlighted with a pink rectangle. Alternatively, it is possible select more than one element at the same time keeping pressed the Shift key and clicking with the mouse over all interested elements.

The primary element of the selection is highlighted with a grey frame with blue corners figure 5. The first element of a multiple selection is the primary element of the selection. In order to resize an element, it is necessary to move the mouse cursor on one of the corners or on one of the selected element sides: For a more careful resize, it is possible to specify the element dimensions directly in the properties window.

If more than one element is selected at the same time, the resizement of one element produces the resizement of all the other elements. Moreover it could be useful to enlarge the report by using the zoom tool which you find on the tool bar figure 5.

It is possible to select a zoom percentage from the combo box fig. During the positioning or the resizement of the elements, it is advised to use integer zoom factors such us 1x, 2x, 4x, etc Positioning and elements order An element is moved by using the mouse: In order to be able to obtain a greater precision in the movement, it is possible to use the arrows keys thanks to which the element will move one pixel at a time.

The same operation, effectuated by keeping pressed the shift key, will produce a movement of the element of 10 pixel. Even if there is a little resistance to the movement, it could be useful to disable the elements dragging through the mouse by selecting the menu EditDisable elements mouse move.

iReport User Manual

The menu ViewShow grid activates the grid which can be used as a reference for the positioning of the different elements. It is also possible to put into action the elements fixing to the grid option through the menu EditSnap to grid.

When the number of elements to organize into the report increases, it is possible to use several tools which can be recalled both from the menu Format and from the contextual menu viewable by pressing the right mouse button after having selected The most of these functionalities needs a selection of more than one element. In this case, the primary element of the selection is taken as reference for the operation to do.

In the table 5. Operation Align left. It aligns the left sides to that of the primary element. Align right It aligns the right sides to that of the primary element. Align top It aligns the top sides or the upper part to that of the primary element.

Align bottom It aligns the bottom sides to that of the primary element. Align vertical axis It centres horizontally the selected elements according to the primary element. Align horizontal axis It centres vertically the selected elements according to the primary element. Align to band top It sets the top value at 0. Align to band bottom It puts the elements in the position at the bottom as much as possible according to the band to which it belongs.

Same width It sets the selected elements width equal to that of the primary element. Same width max It sets the selected elements width equal to that of the widest element. Same width min It sets the selected elements width equal to that of the most narrow element. Same height It sets the selected elements height equal to that of the primary element. Same height max It sets the selected elements height equal to that of the highest element. Same height min It sets the selected elements height equal to that of the lowest element.

Same size It sets the selected elements dimension to that of the primary element Center horizontally It puts horizontally the selected elements in the band based centre of the band Center vertically It puts vertically the selected elements in the band based centre of the band Center in band It puts the elements in the centre of the band Center in background It puts the elements in the centre of the page in the background Join sides left It joins horizontally the elements by moving them towards left Join sides right It joins horizontally the elements by moving them towards right HS Make equal It distributes equally the horizontal space among elements HS Increase It increases of 5 pixel the horizontal space among elements by moving them towards right HS Decrease It decreases of 5 pixel the horizontal space among elements by moving them towards left HS Remove It removes the horizontal space among elements by moving them towards left Table 5.

The elements can be overlapped; it is possible to bring to front or to send back the elements by using the formatting functions Bring to front and Send to back. The zorder is given by the order with which the elements are inserted into the report. The disposition can be viewed in the elements tree, where the elements are viewed in every band from the lowest to the highest.

As we have already said, an element is always linked to the belonging band. If the element is partly or completely out of the belonging band, it will be highlighted with a red frame only for the text elements , in order to indicate that the position is not valid. For other kinds of element, the wrong position is highlighted in the elements tree or during the selecting phase with the frame red corners. If an element partly covers one other element, the corners are highlighted with green colour; while if this element hides completely the other element, the corners are highlighted with pink colour.

Moving an element from a band to an other, iReport changes automatically the belonging band. To specify a different band, use the first combo box present in the element properties window figure 5. If two or more elements are selected, only the common properties are visualized.

If the values of these properties are different, the viewed value will be blank usually By specifying a value for a particular property, this will be applied to all selected elements. Manage elements with the elements tree The elements tree allows to localize and select the report elements easily and with precision.

The report is outlined with a tree structure: With a double click on an element it is possible to open the properties window of the selected object. Also a contextual menu is associated to the elements it is viewable by pressing the mouse right button and only after having selected at least one element: If the node with the band name is selected, the contextual menu changes proposing the band properties operation with which it is possible to approach to the band properties figure 5.

The meaning of all the bands characteristics is explained in the charter 8. Basic attributes All the elements have a set of common attributes presented in the common tab in the properties window figure 5.

It concerns information about the element positioning into the page: The coordinates and the dimensions are always expressed in pixel considering a 72 pixel per inch resolution. All the elements have one of it and their position is always linked to it. The element positioning has always to be made into this band; It is the distance of the top left corner of the element from the top of the band the element belongs to; It is the distance of the top right corner of the element from the left margin of the band; It is the element width; It is the element height; in reality it is a minimum value that can increase during the print creation according to the value of the other attributes; Band top Top.

Foreground It is the colour with which the texts are printed, and the lines and the elements corners are drawn; Background It is the colour with which the element background is filled; Transparent If this option is selected, it allows to make the element transparent; the transparency regards the parts which should be filled with the background; Warning! Not all export formats support the transparency. Remove Line When Blank This option allows to take away the vertical space occupied by an object, if this is not visible; the element visibility is determined by the value of the expression contained in the Print When Expression attribute; thinking about the page as a grid where The three possible values are: If the expression returns true, the element is hidden.

A null value implicitally identifies an expression like new Boolean true which will print the element unconditionally. Graphic elements The graphic elements are drawing objects such as the line and the rectangle; they do not show data generally, but they are used to make prints more readable and agreeable from the aesthetic point of view.

All kinds of elements share the Graphics element tab into the properties window. The line is drawn with the Foreground colour and with the Pen thickness.

Line direction it indicates which of the two rectangle diagonals represents the line; the possible values are TopDown see figure 5. Rectangle The rectangle is usually used to draw frames around other elements. The border is drawn with the Foreground colour with the Pen thickness. The background is filled with the Background colour if the element has not been defined as transparent. The peculiarity of the rectangle in JasperReports it is the possibility to have rounded corners. The rounded corners are defined by means of the radius attribute, that represents the curvature with which you draw the corners, expressed in pixel.

Ellipse The ellipse is the only element that has no own attributes. As for the rectangle, the border is drawn with the Foreground colour and with the Pen thickness. The ellipse is drawn into the rectangle that is built up on the four sides that are tangent to it. Image The image is the most complex graphic object: It is possible to use a own rendering class by using the net. JRRenderable interface. An ipertextual link Hyper Link tab can be associated to an image element.

We will analyse the ipertextual links tab at the end of this chapter. The image characteristics are set up in the Image tab. Image Expression it is a java expression. Its result is an object defined by the Image Expression Class attribute; on the grounds of the return type, the way the image is loaded changes; Image Expression Class it is the expression return type.

The table 5. Type java. Interpretation A string is interpreted like a file name; JasperReports will try to interpret the string like an absolute path; if no file is found, it will try to load a resource from the classpath with the specified name. Right expressions are: It specifies a File object to load as an image. A right expression could be: File c: It specifies the java.

URL object.

It is useful when you have to export the report in HTML format. URL http: InputStream It specifies a java. InputStream object which is ready for reading; in this case we do not consider that the image exists and that it is in a file: It specifies a java. Image object; it is probably the simplest object to return when an image has to be created dynamically. It specifies an object that uses net.

Table 5.

In the examples we have just explained, MyUtil represents an invented class. If you want to use an external class by calling a static method to run particular elaborations, it is necessary to use it with the package it belongs to for example it. MyUtil or to specify its package in the import menu ShowImport directives in the report. The methods we explained in the examples are static, but when we will talk about the variables, we will see how to instance a class at the beginning of the print and how to use it into the expressions.

By using fields, variables and parameters into the Image Expression it is possible to load or to produce images in a parametric way like it would happen, for example, for the detail of an illustrated catalogue where every product is associated to an image. Scale Image it defines how the image has to adapt to the element dimension; the possible values are three: Vertical alignment this attribute defines the image vertical alignment according to the element area; the possible values are: Horizontal alignment this attribute defines the image horizontal alignment according to the element area; the possible values are: The evaluation time is a very interesting functionality and it is well explained in the JasperReports manual.

The possible values are: For the image element and for the text elements it is possible to visualize a frame or to define a particular padding for the four sides. It is a space between the element border and its content. Border and padding are specified in the border tab and they are properties that have been introduced from the JasperReports 0.

It is possible to select type and colour of the border to draw for every side of the element. The border types are: A simple preview of the graphic effect produced by the selected border is visualized in the centre of the border tab. Text elements Like the graphic elements, also the elements that allow to view the text have a common properties tab: In the font tab are set the properties of the text shown in the element, so not only the font dimension and type of the character , but also the text alignment, the eventual rotation and line space.

From it will be taken all the character properties; the presets fonts are defined at report level and it is possible to manage them by selecting the menu ViewReport fonts; Line spacing it is the interline value; the possible values are: The other characteristics of the font tab are explained in the chapter 6 which is completely dedicated to the Font.

The text element properties can be modified also by using the text toolbar fig. Static text The static text is used to show a non-dynamic text in the report. The only parameter that distinguishes this element from a generic text element is the static text tab where the text to view is specified: Text field A text field allows to print the value of a java expression.

The simplest case is the print of a string java. String coming from an expression like this: Hello World! In this case the result is exactly a static field created with a little bit more of work, because the string of the example is an expression of constant value; in reality the JasperReports does not directly associate the data to print to particular text elements like it happens in different tools of the report where the text element rappresents implicitly the value of a database field: At the same way for the images, an hypertextual link can be associated also to the textfields and it is defined by the HyperLink tab.

Textfield Expression Class it specifies the return type of the field expression; the possible values are many, they include all the java objects which comprehend the SQL types and some classes for the manage of the dates. In the following table all the selectable types are listed. Object java. Boolean java. Byte java.

Date java. Timestamp java. Time java. Double java. Float java. Integer java. InputStream java. Long java. Short java. BigDecimal java. String Table 5. In this list also the java.

Object type is included. It can be used if no one of the other types is applicable to the associated data. JasperReports is able to format dates and numbers; the following tables summarize with some examples the letters and their meaning for the creation of patters of data and numbers. Here there are some examples of formatting of dates and timestamp: Dates and Time Pattern Result "yyyy.

Location Number Number Number Localized? Need not be quoted in prefix or suffix. Separates positive and negative subpatterns. Multiply by and show as percentage Multiply by and show as per mille Currency sign, replaced by currency symbol. If doubled, replaced by international currency symbol. If present in a pattern, the monetary decimal separator is used instead of the decimal separator. To create a single quote itself, use two in a row: Here there are some examples of formatting of numbers: Dates and Time Pattern Result " , 0.

Thanks to the create button fig. Textfield Expression it is the expression that produces the value to print; it has to return an object of the same type declared in Textfield Expression Class; It is possible to transform a StaticText in a Textfield by selecting it and pressing the F3 key. In order to change quickly the expression of one or more generic text elements, select them and press F2.

Subreport The subreport is an element that is able to contain in it an other report that is created starting from a jasper file and feed by a datasource that is specified in the subreport properties.

Following the subreport characteristics are briefly illustrated. However, because of the complexity of this subject, we will deeply explain the subreports in an another chapter.

Parameters Map Expression it identifies an expression which is valuated at runtime; the expression must return a java. Chart For all the details regarding the charts, see chapter Barcode This element allows to create and print dynamically a value in the form of barcode. The possible values are listed in table 5. Hyper Links The image and textfield elements can be used both as anchor into a document, and as hypertextual links towards external sources or other local anchor.

An anchor is a kind of label that identifies a specific position into the document. The hypertextual links and the anchors are defined by means of the Hyper Link tab fig. This is divided in two parts. In the superior part there is a text area through which it is possible to specify the expression that will be the name of the anchor.

This name can be referenced by other links. The inferior part is dedicated to the link definition towards an external source or a position into the document. JasperReports allows to create five types of hypertextual links: Through the Hyperlink target it is possible to specify if the exploration of a particular link has to be made into the current window it is the predefined setting and the target is Self , or into a new window Blank target.

Not all export formats support the hypertextual links. Reference The Reference link indicates an external source which is identified by a normal URL and it is ideal to point, in example, to a servlet to manage record drilldown functionalities.

The only expression required is the Hypelink Reference Expression. LocalAnchor To point to a local anchor means to create a link between two locations into the same document.

It can be used, for example, to link the titles of a summary to the chapters they refer to. To define the local anchor it is necessary to specify the Hyperlink Anchor Expression which will have to produce an anchor valid name. LocalPage If instead of pointing to an anchor, you want to point to a specific current report page, it is necessary to create a LocalPage link.

In this case it is necessary to specify the pointed page number by means of the HyperLink Page Expression the expression has to return an Integer object. RemoteAnchor If you want to point to a particular anchor that is present in an external document, you will use the RemoteAnchor link.

In this case the URL of the pointed external file will have to be specified in the Hyperlink Reference Expression field and the name of the anchor will have to be specified in the Hyperlink Anchor Expression field.

RemotePage This link allow to point to a particular page of an external document. In this case too, the URL of the pointed external file will have to be specified in the Hyperlink Reference Expression field and the page number will have to be specified by means of the HyperLink Page Expression. Fonts describe the characteristics shape and dimension of text.

In JasperReports it is possible to specify the font properties for each element. Moreover it is possible to define a set of global fonts named report font and associate them to an text element.

This global font will then be used for the text contained in the element. The font Usually a font is defined by four basic characteristics: This is a string that specifies the name of the encoding to be used for the character coding. If the report is not exported to PDF format, the font used is the one specified in font name and enriched with the specified attributes.

Other attributes are ignored since they are inherented from the specified PDF font. In order to do this, it is necessary for the external fonts file with. It is necessary to avoid adding hundred's of TrueType fonts to the classpath because this slows down the start of iReport.

In the Font name combo box only the system fonts, managed by the Java Virtual Machine, are shown and usually they are inherited by the operative system. This means that if you want to select an external TTF font, to use in non-PDF reports, it is necessary to install it on your system before use. The combo box True Type font will be enabled. In it all the True Type fonts found in the classpath will be present.

Encoding The character encoding problem is one of the most obscure of JasperReports; in particular this problem occurs when you have to print in PDF format.

So it is very important to choose the right PDF encoding for the characters. The encoding specifies how the characters have to be interpreted: However some JVM versions do not support the encoding versions before 1.

iReport Tutorial

If you have some problems with reports of non-standard characters in PDF format, make sure that all the fields have the same encoding type and verify the charset used by the database from which the report data is read. Use of Unicode characters It is possible to use the Unicode syntax in order to write non-standard characters such as the Greek, Cyrillic and Asian characters ; the Unicode code has to be specified in the expression that identifies the field text.

Report font To define a set of global fonts, select Report fonts from the View menu. This will open a window for managing the global fonts. The inserting scheme of a new global font is viewed in figure 6. To use a global font in a textfield, select it from the Report font combo box figure 5.

Limiting itself to set the property values of the selected report font to the selected element and to copy all the attributes of the global font to the text element.

In fact the global fonts were born with the aim to economize the XML source, by avoiding having to specify all the font characteristics for every single field. Since this work is completely automated in iReport, the optimizing has little importance. However, because of this, the attempt to centralize the report fonts managing is bypassed, because, if present, JasperReports uses the attributes specified at element level and they are always specified by iReport.

More simply, if a global report font is used in a text element, its characteristics are saved with the text element and essentially overrides the global report font. At the moment it is not possible to define a set of fonts to be used in more than one report. These objects are used in the expressions, they can change their value during the print progression and they are typed, that is all these objects have a type which correspond to a java class such as String or Double.

Fields, parameters and variables have to be declared in the report in order to be used. By selecting from the main menu View we find, among the others, the Report fields that is the fields , Report variables and Report Parameters submenus. Each of these three submenus allows us to view the window for managing all these objects figure 7.

Through this window it is possible to declare, modify and remove fields, variables and parameters. Fields A print is commonly created starting from a data source: In order to declare a field, press the new button and a window as in figure 7.

The fields are identified by a name, by a type and by a facultative description. It is not possible to choose the field type in an arbitrary way. If the field type is not present among the predefined types, it is possible to declare the field as java. Object and cast it to the required type in the expressions where the field is used.

In an expression you can refer to a field by using the syntax: Person object, write: The number of fields in a report could be really high also reaching reaching the hundreds. For this reason in iReport different tools exist for the declaration of fields retrieved by particular datasources typologies. Registration of fields of a SQL query The most widely used tool is the one which allows us to declare or record the fields of a SQL query in order to use them in a report.

To do this it is necessary first of all to open the ReportQueryDialog pressing the button. The window for the query definition will appear. It will be used to fill the report if the report is really created starting from a SQL query. After being sure that the connection to the DBMS is active go to page 15 to see how to do it , insert a query, for example: By selecting the fields, they will be registered in the values window fig.

To register the fields, it is necessary to select them from the list; if the query contains some mistakes, deselect the Automatically Retrive Fields checkbox and read the fields manually with the Read fields button.

In this case all the fields will be of type String: This is the case of the JavaBean collections where the record concept is substituted by that of the java object. In this case the fields are the object attributes. By selecting the JavaBean Datasource tab, it is possible to register the fields which are read by a specified java object, in this case the object: By pressing the Read javabeans attributes button after having specified the name of the class to analyse, the attributes are extracted and presented as fields.

Later we will see the exact way this datasource is functioning, but in the JavaBean Ext Datasource tab there is a tool similar to that seen for the introspection of a JavaBean. This tool doesnt return a plain list of the available attributes for the explored JavaBean, but permits a more in depth exploration using a tree view where primitive attributes like the strings and numbers are represented by leaves, others are more complex types other bean that can be further exploded.

The way to reach a specific data in the Bean is stored in the field description with a syntax similar to that used for the java packages. In order to add a field to the list, it is necessary to select a tree node and press the Add field s button. Fields and textfield To print a field in a text element, it is necessary to set correctly the expression and the textfield type, and if it is necessary, to define a correct pattern for the field formatting.

It is possible to automate the setting of the expression and of the type by draging the field from the fields list into the desired report band drag n drop feature. Parameters The parameters are values that usually are passed to the report from the program which creates the print and they can be used both to guide particular behaviours during the running phase such as the application of a condition in a SQL query , and to supply additional data to the print context such as an Image object containing a chart or a string with the report title.

As with the fields, the parameters are also typed and they have to be declared at design time. The parameters types can be arbitraries. At the moment the property is for prompting is not used by iReport and it is not relevant for the aim of the print: In an expression we refer to a parameter by using the syntax: Remember that the parameters as the variables are java objects, so it is not possible to use for the default value an expression like this 0. Use of parameters in a query As already said, a possible use of the parameters is to filter a SQL query.

Suppose you want to print information about a particular customer identified by their Id not known at design time. Our query will become something like: JasperReports will transform this query in: If you want to avoid this kind of parameters managing, it is possible to use the special syntax: Map interface.

Consider the code listed on the page 27, in particular the following lines: HashMap object. To use in the report a parameter that contains for example the title of our report like it is shown in the figures 7. It is not mandatory to pass from the program a value for all the parameters declared in the report. If is not explicitly set a value for a parameter by the program, JasperReports will use the Default Value Expression to calculate the predefined value of the parameter; the empty expression is synonymous of null.

In reality the example is not very interesting because the data type passed is a simple string, however it is possible to pass to the report through the Map some Image or the instance of a datasource usable to feed a particular subreport.

Moreover it is important to fill a parameter with an object having the same type of the declared type for the same parameter, otherwise a ClassCastException will be thrown. Built-in parameters JasperReports provides some built-in parameters they are internal to the reporting engine , which are readable, but not modifiable from the user.

These parameters are presented in table 7. Map passed to the fillReport method and it contains the parameters values defined by the users. It is the datasource used to create the report when it is not used a JDBC connection.

It represents the scriptlet instance used during the creation; if no scriptlet has been specified, this parameter focuses on an instance of net. Variables The variables are objects used to store the results of calculations such as subtotals, sums, etc As the fields and the parameters, the variables are typed, that is its mandatory to declare the java type of which they are instances of the Variable Class Type.

See the meaning of each field. Variable name it is the name of the variable; in a similar way to what happens for fields and parameters, in the expressions we refer to a variable through the following syntax: String and java. Double; Calculation Type it indicates the type of a predefined calculation of which the result has to be stored by the variable; the predefined value is Nothing that means dont perform any calculation automatically; JasperReports perfoms the specified calculation changing the variables value for every new record that is read by the datasource: The calculation types are the following: Calculation types It does no kind of calculation type; it is used when the calculation is intrinsic into the expression that is specified from the user and that will be valuated to each new record.

Count It counts how many times the expression result is different from null; do not confuse it with sum that makes real sums based on the expression numerical value. Sum It adds to each iteration the expression value to the variable current value. Average It makes the arithmetic average of all the expressions received in input. Lowest It returns the value of the lowest expression received in input. Highest It returns the value of the highest expression received in input. StandardDeviation It returns the standard deviation of all the expressions received in input.

Variance It returns the variance of all the expressions received in input. System It makes no kind of calculation and the expression is not evaluated; in this case, the report engine keeps only in memory the last value set for this variable; it can be used to store the calculation result performed for example using a scriptlet.

Table 7. Reset types The Initial Value Expression is always ignored The variable is initialised only once at the beginning of the report creation by using the Initial Value Expression Page The variable is initialised again in each new page Column The variable is initialised again in each new column or in each page if the report is composed by only one column Group The variable is initialised again in each new group the group we refer to is specified in Reset Group Table 7.

Custom Incrementer Factory Class it is the name of a java class that increases the JRIncrementerFactory interface, useful to define operations such as the sum for non-numerical types; Variable Expression it is the java expression that identifies the input value of the variable to each iteration; Initial Value Expression it is an expression of which evaluation produces the variable initial value.

Built-in variables As for the parameters, JasperReports puts at the user disposal some built-in variables that are directly managed by the reporting engine , they are readable, but not modifiable by the user. These variables are presented in table 7. At Report time this variable will contain the total number of pages It contains the current number of columns Current number of records that have been processed Current number of records that have been processed in the current page Current number of records that have been processed during the current column creation Current number of records that have been processed for the group specified as variable prefix.

In the chapter 4 we explained the report structure, and we have seen how the report is divided in bands, horizontal portions of page that are printed and modified in height according to the band properties and content. Here we will se how to use the groups, how to create some breaks in the report, how to manage subtotals etc Bands JasperReports divides a report in seven main bands and the background eight bands in total.

To these other two bands are added, the group footer and the group header. Through this window it is possible to modify the main properties of a band, its height, expressed in pixel Band Height , the possibility for the band to be break if it is overflow from the page Split allowed and the Print When Expression, that is an expression the must return a Boolean object and of which valuation determines the print.

In this case the empty expression represents implicitally the expression: Into the expression it is possible to use fields, variables and parameters, by paying attention to produce as a result a Boolean object. Even if it is specified esplicitly, the band height can increase if one or more elements it contains grows vertically it can happen for textfield elements of which contents exceed the specified dimensions or for the subreports.

JasperReports guarantees that the band height is never inferior to that specified.

In order to resize a band it is possible to use the bands window figure 8. A double click on the inferior margin allows to resize the band by adapt the height to the content. If one or more consecutive bands have zero height, it is possible to increase its dimension by keeping press the Shift button and to move towards the bottom the inferior margin in the band that precedes it.Management of a library of standard objects for example, numbers of pages.

Need not be quoted in prefix or suffix. If everything is ok, the following dialog window will appear:. However the use of an expression allows some kind of freedom for the production of the datasource. The possible values are listed in table 5. Disposition can be fun. Here we will se how to use the groups, how to create some breaks in the report, how to manage subtotals etc The predefined directory is the one stored into the user.

At the end of the configuration, set Northwind as the active connection Build Set active connection.