Manual de ireport y net beans

Páginas: 6 (1315 palabras) Publicado: 23 de mayo de 2011
http://jasperforge.org/uploads/publish/ireportwebsite/IR ...

Home > Tutorials & Help > De s igning a re port

Designing a report
by Giulio Tof f oli In this tutorial, we cov er the basics of how to design a report. The report creation process has three main steps: 1. Creating a data source or a database connection used to f ill the report. 2. Designing the report, including the lay out ofits elements and parameters to represent the data. 3. Runing the report, which includes compiling the JRXML source f ile in a Jasper f ile and f illing in the data f or export or onscreen display . To keep things simple, this tutorial uses a plain JDBC connection, which is a connection to a database. The data to print is retriev ed using an SQL query embedded in the report. Let's start by creatingthe connection. Y ou can use any database and table y ou want, but if y ou want to test the same exact query and create the same report as the tutorial, y ou can use the sample database included with JasperReports. Once y ou download JasperReports (f rom here) and unpack the archiv e, go to the demo/hsqldb directory and run the f ollowing command: java -cp ../../lib/hsqldb-1.8.0-10.jarorg.hsqldb.Server When the HSQLDB serv er starts up correctly , the terminal output appears as f ollows:

Figure 1 To create the new connection in iReport, open the datasources/connections dialog by clicking its icon in the tool bar, as shown in Figure 2.

Figure 2 Click New, choose Database JDBC connection as shown in Figure 3, and use the f ollowing settings f or the sample HSQL database, as shown inFigure 4 below: Name: JasperReports Sample JDBCDriv er: org.hsqldb.jdbcDriv er Url: jdbc:hsqldb:hsql://localhost Username: sa Password: [none]

1 de 6

28/02/11 23:24

http://jasperforge.org/uploads/publish/ireportwebsite/IR ...

Figure 3

Figure 4

As said abov e, y ou can use y our f av orite database, in that case y ou hav e to prov ide the right URL, the JDBC driv er andcredentials. iReport proposes a list of well known database driv ers. If the one y ou need is not present, just ty pe the name. If it is present and it is highlighted in red it means that the driv er is not av ailable in the classpath and must be added. To do so, select Tools > Options > iReport > Classpath and add the required JARs to the classpath. Also, it's good practice to test the connection bef oresav ing it. When done, the new connection appears in the connections list and is automatically selected as the def ault, activ e connection:

Figure 5 Now, let's create the new report. Select File > New.

2 de 6

28/02/11 23:24

http://jasperforge.org/uploads/publish/ireportwebsite/IR ...

Figure 6 In the template chooser that appears, select a blank report and click Open this Template.Select a name and location to story the new f ile, click next and then f inish. Y our blank report now appears in the designer:

Figure 7 Click the button representing a database query in the designer tool bar:

Figure 8 This opens the Query dialog to def ine the query that retriev es data to f ill the report. The SQL query is stored inside the report and can accept parameters to f ilter thedata using the sy ntax $P{} (f or standard parameters) and $P!{} (to use a parameter as SQL chunk). Again we want to keep things simple in this tutorial, so we will not use any parameters. Ty pe the f ollowing query to select all the f ields/columns in the orders table: select * from orders

3 de 6

28/02/11 23:24

http://jasperforge.org/uploads/publish/ireportwebsite/IR ...

Figure 9 Ofcourse, y ou can use any table f or this example. The orders table is av ailable in the sample database we are using. If y ou don't know SQL, y ou can use the v isual SQL query builder by clicking the Query designer button. As y ou ty pe the query , iReport executes it to extract all the f ields (columns) av ailable in the query . The f ields are listed on the bottom portion of the window. If...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Ejercicios De Net Beans Con If
  • Fondos Net-Beans Java
  • Sistema de matriculacion net beans
  • Net Beans
  • Manual ireport
  • Manual de ireport
  • Manual de visual basic .net
  • Manual de visual basic .net

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS