VIVEK SHAH

011011010010000001100001011001000110010001101001011000110111010001100101011001000010000001110100011011110010000001101010011000010111011001100001 Click Here

Custom Search

The Main Features of iReport Plugins For Netbeans

The following list describes some of the important characteristics of iReport:
• 98% of JasperReports tags supported
• Visual designer wysiwyg with tools for draw rectangles, lines, ellipses, text fields fields, charts, sub reports...
• Built-in editor with syntax highlighting for write expression
• Support for Unicode and non Latin language (Russian, Chinese, Korean,...)
• Document structure browser
• Integrated compiler and exporter
• Support of all JDBC compliant databases
• Support of all kind of JRDataSource
• Wizard to create automatically reports
• Support for sub reports
• Save backup
• Support for templates
• Facilities for fonts 



Creating a NetBeans database JDBC connection


The first step is to create a database connection, which will be used by the report data sources. Follow the listed steps:
  1. Select the Services tab from the left side of the project window.
  2. Select Databases.
  3. Right-click on Databases, and press New Connection….
  4. iReport 3.7
  5. In the New Database Connection dialog, set the following under Basic setting, and check theRemember password checkbox:
Option
Value
Driver Name
MySQL (Connector/J Driver)
Host
localhost
Port
3306
Database
inventory
User Name
root
Password
packt
iReport 3.7
  1. Press OK. Now the connection is created, and you can see this under the Services | Databasessection, as shown in the following screenshot:
iReport 3.7



Creating a report data source


The NetBeans database JDBC connection created previously will be used by a report data source that will be used by the report. Follow the listed steps to create the data source:
  1. From the NetBeans toolbar, press the Report Datasources button. You will see the following dialog box:
  2. iReport 3.7
  3. Press New.
  4. Select NetBeans Database JDBC connection, and press Next >.
  5. iReport 3.7
  6. Enter inventory in the Name field, and from the Connection drop-down list, selectjdbc:mysql://localhost:3306/inventory [root on Default schema].
  7. iReport 3.7
  8. Press Test, and if the connection is successful, press Save and close the Connections / Datasources dialog box.
iReport 3.7

Creating a simple report


We are going to create a report, which shows the list of products. Just follow the listed steps:
  1. Go to File | New File….
  2. Select Report from the Categories: section and Report Wizard from the File Types: section, as shown in the next screenshot:
  3. iReport 3.7
  4. Press Next >. Select the Simple Blue layout and press Next > again.
  5. iReport 3.7
  6. Enter ProductListNB.jrxml as File Name:, and Browse… to the reports folder.
  7. iReport 3.7
  8. Press Next >.
  9. iReport 3.7
  10. Select inventory from the Connections / Data Sources options.
  11. Write the following SQL command as the query:

      SELECT ProductCode, Name, Description
      FROM Product
  12. Press Next >. You will see the following screen:
  13. iReport 3.7
  14. Select all the fields, press >>, and then press Next >.
  15. Press Next > again without selecting any group.
  16. iReport 3.7
  17. Press Finish. You will see the following output:
  18. iReport 3.7
  19. Click on the Preview button to see the output, as shown in the following screenshot:
  20. iReport 3.7
  21. You can design the report in the Designer section as per your design requirements.



Creating a parameterized report


We are going to create a report in NetBeans that shows the personal information of a particular customer. Follow the listed steps:
  1. Go to File | New File….
  2. Go to File | New File….
  3. Select Report from the Categories: section and Report Wizard from the File Types: section.
  4. Press Next > and select Simple Blue and press Next > again.
  5. Enter ParticularCustomerNB.jrxml as the File Name:.
  6. Browse… to the reports folder.
  7. Press Next >.
  8. Select inventory from the Connections / Data Sources drop-down list.
  9. Write the following SQL command as the query:


    SELECT * FROM Customer
    iReport 3.7
  10. Press Next >.


    iReport 3.7
  11. Select all the fields, press >>, and then press Next >.>>
  12. Press Next > again without selecting any group.
  13. Press Finish. You will see the Designer view of the report.
  14. From the Report Inspector (see bottom left of the designer), select Parameters. Right-click on it, and click on Add Parameter.
  15. iReport 3.7
  16. A parameter named parameter1 is added to the Parameters list. Select parameter1, and go to the parameter Properties window (see bottom-right of the designer).
  17. iReport 3.7
  18. Change the Name to customerNo.
  19. Change the Parameter Class to java.lang.Integer.
  20. Check the Use as a prompt checkbox.
  21. Now, click on Report query (beside the Preview button), and replace the query with the following one:

      SELECT * FROM Customer
      WHERE CustomerNo = $P{customerNo}
  22. iReport 3.7
  23. Press OK and Preview the report. Input the customerNo, and see the output.

0 comments:

Post a Comment