teshimaryokan.info Biography IREPORT MANUAL PDF

Ireport manual pdf

Monday, April 8, 2019 admin Comments(0)

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.


Author: SUMIKO OLESON
Language: English, Spanish, Indonesian
Country: Malaysia
Genre: Politics & Laws
Pages: 765
Published (Last): 21.01.2016
ISBN: 887-3-42860-365-2
ePub File Size: 29.70 MB
PDF File Size: 19.79 MB
Distribution: Free* [*Regsitration Required]
Downloads: 23911
Uploaded by: SEASON

iReport Designer, JasperReports Library, JasperReports Server, Jaspersoft This is version UGI of the iReport Ultimate Guide. Unexpected server response. More Information Less Information. Close. teshimaryokan.info 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.

With a double click on an element it is possible to open the properties window of the selected object. Title This is the first visible band. Using Parameters in a Query. Save the subreport for example with the name customers. The next method can be called as many times as there are records present or represented from the datasource instance. Band Height.

Defining Trend Lines. Widget Types. Creating Widgets. Specifying Widget Data. Chapter 14 Lists, Tables, and Barcodes. Working with the List Component. Parameters and Variables in a List Element. List Component Issues. Print Order: Vertical and Horizontal Lists. Other Uses of the List. Creating a Table. Table Structure. Editing the Table Layout. Editing the Dataset Run.

Working with Columns. Working with Barcodes. Barbecue Component.

iReport Tutorial

Barcode4J Component. Chapter 15 Subdatasets. Chapter 16 Crosstabs. Modifying Cells. Understanding Measures. Chapter 17 Internationalization. Chapter 18 Scriptlets. Chapter 19 Additional Tools.

Current Date Tool. Page Number Tools. Appendix A Chart Theme Example. Through an intuitive and rich graphic interface, iReport lets you rapidly create any kind of report very easily. With Version 3. Even though the user interface appears pretty much the same, a complete new design of the iReport core and the use of the NetBeans platform will allow us to quickly create new features, making iReport even easier to learn and use. With this iReport Ultimate Guide youll learn how to add visual and analytic features to complex reports with charts, images, and subreports.

This informative guide has transformed many a newcomer into designers of pixel-perfect, complex, and highly interactive reports. It is written and updated by Giulio Toffoli, iReport project founder and architect. This chapter has the following sections:. It has complete tools for drawing rectangles, lines, ellipses, textfields, labels, charts, subreports and crosstabs. Built-in editor with syntax highlighting for writing expressions.

Browser for document structure. Integrated report compiler, filler, and exporter. Support for all databases accessible by JDBC. Virtual support for all kinds of data sources. Wizard for creating reports and subreport automatically. Support for document templates.

TrueType fonts support. Support for localization. Extensibility through plug-ins. Support for charts. Management of a library of standard objects for example, numbers of pages. Drag-and-drop functionality. Wizard for creating crosstabs. Styles library. Integrated preview. Error manager. JasperServer repository explorer. Additional features in Professional Edition. Version 3.

Enhanced page formatting, including band features that enable multiple bands and subbands of the same type and a new Page Format dialog. Keep Together and Footer Position properties for groups. Query executers and fields providers to enable you to use custom query languages. The iReport team comprises many skilled and experienced programmers who come from every part of the world.

They work daily to add new functionality and fix bugs. The iReport web site is at http: If you need help with iReport, there is a discussion forum in English. This is the place where you can send requests for help and technical questions about the use of the program, as well as post comments, discuss implementation choices, and propose new functionality.

There is no guarantee of a prompt reply, but requests are usually satisfied within a few days time. This service is free. If you need information concerning commercial support, you can write to sales jaspersoft. Please report bugs at the following address: There is also the ability to suggest patches and integrative code. All members of the iReport team value feedback from the user community and seriously consider all suggestions, criticism and advice coming from iReport users.

The Pro components of JasperReports Professional require a commercial license. The commercial license can be installed using the License Manager. Click Install License and select the license file to use.

If the license is not valid, a message will explain the problem and what do to. If you do not purchase the commercial license and the evaluation license expires, iReport shows the following message at startup. You can still use iReport with the expired license, but you cannot run reports that use Pro components:.

Flag for inappropriate content. Related titles. Jump to Page. Search inside document. This chapter has the following sections: You can still use iReport with the expired license, but you cannot run reports that use Pro components: Figure 1. Igor Ciobanu. Fagner Alves de Almeida.

Naidu Venkat. Achmad Zaki Mubarok. Jed Tedor. Pawan Singh.

Sample Ireport Ultimate Guide 3 PDF 15582

Deepak Dewani. Alberto Fernandez Reyes. Thomas Mpourtzalas. Esteban Salazar. Souko Kin. Deepthi Vrindavan. Aparna Janwalkar. Swetha Kommineni. David Carpenter. Popular in Software. Paulo Simoes. Govindasamy Soundararajan. Christy Elias. Joydeep Sengupta. Ravi Kumar. Neeraj Gupta. Livington Briones. Masri Wel. Ergon Zederan. Carlita Suntaxi.

Jai Narain. If you need information concerning the commercial support, you can write to gt businesslogic. Please send bug notices to the following address: There is also the ability to suggest patches and integrative code.

In order to be always up-to-date about the development of the program, you can join the mailing list of the project at this address: Acknowledgements iReport contains code and ideas from many people. Though I run the risk of forgetting somebody, I would like to thank the following people for their contribution to this project: If you want to compile iReport sources, you should install Jakarta Ant version 1.

As for hardware, like all java programs, iReport eats a lot of RAM and so it is necessary to have at least Mb of memory and about 20 Mb of free space on disk.

Download It is possible to download iReport from the Project Page on SourceForge where you can always find the last released iReport distribution http: Three different distributions are available: This is the official binary distribution in tar gz format.

This is the official distribution of sources in zip format. Every distribution contains all needed libraries from third parties necessary to use the program and additional files, such as templates and base documentation in html format. If you have the cvs executable for command line, write this: In this way the CVS client will download all the iReport files in repository into the local computer, with also documents, libraries and all that is useful to compile the full project.

Compile iReport The distribution with sources contains a build. Download iReport-x. Open a command prompt or a shell, go to the directory where archive was uncompressed, go to the iReport directory and write: Start and base configuration If you preferred downloading iReport binary version, uncompress the downloaded archive into the directory of your choice, for example c: On the first execution, iReport will create a directory named.

Here the personal settings and the configuration of the program are saved. If it is not possible to create this folder, this could cause undesirable affects in the program and it may not be possible the configuration. In this case it could be necessary to create the directory manually. Before proceeding to the program configuration, it is necessary to copy tools. The absence of this file can produce some exceptions during the compilation of a report carried out by using classes contained in this java library.

On MacOS X the tools. The iReport initial configuration consists of: Other configuration settings will be explained subsequently. In order to proceed to the configuration, run iReport and select the menu Options Tools. The window in figure 2. In the tab Compiler you can set where iReport stores jasper files that are compiled.

By default, iReport uses the current directory as destination for compiled Often it is useful to specify a specific directory for saving compiled files; this directory is usually the same in which the source of the report is located. In this case, check Use the reports directory for compiles checkbox. Complete the configuration by specifying the external programs to use with different output formats of reports and the editor to use for modifying XML source.

Restart iReport to set all chosen options. Test the configuration by creating a new blank report menu File New Document , and confirming all features proposed for the new report.

Then click on the Run button on the toolbar. If everything is ok, you will be prompted to save the report in a jrxml file, and a corresponding jasper file will be created and a preview of a blank page will appear.

This means that iReport has been installed and configured correctly. Create a JDBC connection The most common datasource for filling a report is typically a relational database. A new window will appear for the configuration of the new connection Figure 2. In the new frame, write the connection name i.

My new connection and select the right JDBC driver. You can automatically create the URL by entering the server address and database name in the corresponding boxes and press the Wizard button.

To complete the connection configuration, enter the username and password for the access to the database. If you want to save the password, select the Save password checkbox. If you do not want to save them, do not select the Save password checkbox..

Test the connection by pressing the Test button. It is better to test the connections before saving and using them. In chapter 10, we will explain extensively all the configuration modalities of the datasources.

At the end of the test, press the Save button to store the new connection. In this way we have created a new datasource, so we have to tell iReport to use it as a predefined datasource. Select from the menu build Set active connection item. Then select our connection from the list and press the OK button Figure 2. From now on iReport will use this connection for every operation which needs an access to the database in particular the acquisition of the fields selected through SQL query and prints creation.

The first report Now that we have installed and configured iReport, and prepared a JDBC connection to the database, we will proceed to create a simple report using the Wizard. To be able to use it, copy the hsqldb.

In order to set up the database connection used in this example supplied with the handbook , use the following parameters: Proprieties Value. At the end of the configuration, set Northwind as the active connection Build Set active connection.

Select the menu File Report Wizard. This loads a tool for the step by step creation of a report. Insert in the text area a SQL query in order to select data that will go to fill your report, for example: The clause order by is important to the following choice of the grouping.

Manual pdf ireport

We will discuss the details later. Select the fields you wish to include and press Next. Now that we have selected the fields to put in the report, you will be prompted to choose what fields you wish to group by if any Fig. Using the wizard, It is possible create until four groups. Others can be defined afterwards. The next step of the wizard allows you to select the print template, which is a model that can be used as base for the creation of the report.

With iReport some very simple templates are supplied, and we will see how to create some new ones. For the moment it is enough to know that there are two types of templates: For the first report select a tabular template, in particular the classicT one T means tabular. Once you have chosen the template, press Next.

The last screen of the wizard will appear and it will tell you the outcome of the operation. Press Finish to create the report which will be viewed in the iReport central area, ready for execution. Before being able to execute the final print, you will have to save the report source created trough the wizard and compile it.

These operations can be done all at once by pressing the button Run report using a connection that is on the toolbar. After you press the Run report using a connection button, you will be asked for the name under which to save the file. Save the file with the name report1.

In the console that is in the part below of the main window, some messages will appear. They will tell you about what is happening: At the end of the operation, if everything is ok, the report will be shown in the default program for opening PDF files. The PDF format is the predefined format of export.

Command line options It is possible to specify some start up parameters on the command line. All parameter are not case sensitive. They can be truncated cut until they remain not ambiguos for example the option ireport-home can be specified as i; no other options starts with the letter "i"; in this way the command line interpreter will consider i as a not ambiguous truncation of the ireport-home option.

It is possible to obtain the options list by writing: The following table explains the different available options. It refers to the iReport 0.

Option Description. Specifies the filename for loading an alternate configuration. Specifies the directory where temporary files will be saved. Specifies the user home.

The predefined directory is the one stored into the user. Using this option, iReport will print in output the version and it will go out immediately. If Ant is used, it is not possible to specify these options directly from the command line, but it will be necessary to modify the build.

It is the most widely distributed and powerful free software library for report creation available today. In this chapter we will illustrate JasperReports base concepts for a better understanding of how iReport works. Other information and examples are directly available on the official site at http: This means that JasperReports can be freely used on commercial programs without buying very expensive software licences and without remaining trapped in the complicated net of open source licences.

This is fundamental when reports, created with iReport, have to be used in a commercial product: Without the right commercial licence available upon request , iReport can be used only as a development tool, and it cannot be part of a program that is not distributed with the GPL licence. The report life cycle The report life cycle is very similar to one of a java class. In Java, this is described by a source file, that is, a file with a java extension, written according to its language rules.

The source is compiled through the compiler, creating a class file with a. When the class is used, it is loaded into memory and instanced by the java interpreter; during execution the attributes will be emphasized. In library version 0. JasperReports XML ; it replaces the generic. These source files are compiled to create a jasper file. A jasper file. The jasper file is loaded in a runtime by your application.

It is joined to records coming from a datasource in order to create a print, which can be exported in the desired format e. Therefore, it is possible to define two distinct action groups: Jrxml sources and jasper files As already explained, a report is described by an XML file according to the definitions found in the DTD jasperreport. This source file is defined by a series of sections, some of them concerning the reports physical characteristics, such as the dimension of the page, the positioning of the fields, the height of the bands, etc; and some of them concerning the logical characteristics, such as the declaration of the parameters and variables, the definition of a query for the data selection, etc Simplifying a lot, it is possible to outline the sections of a jrxml source, as follows: Figure 3.

In reality, the code of Listing 3. This is because iReport does not produce optimised code e. During compilation done through some JasperReports classes of the jrxml file, the xml is parsed and loaded in a JRBaseReport object. JRBaseReport is a rich data structure which allows one to represent the exact xml contents in memory.

All of the parsed expressions are loaded and the java class source is produced. This source, which extends the JRCalculator, is compiled by means of a normal java compiler and the class created on disk is loaded as a byte buffer. The JasperReport class that you have obtained, is serialized into the jasper file which is then ready for loading at any given time.

The JasperReports speed is due to the fact that all of the reports formulas are compiled into java native bytecode and the report structure is verified during compilation, not runtime. Data sources and print formats Without the possibility of filling a print through some dynamically supplied data, the most sophisticated and appealing report would be useless. JasperReports allows one to specify fill data for the print in two different ways: 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.

Pdf ireport manual

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

Manual pdf ireport

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.

iReport Tutorial

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.

JasperReports Library

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.