Monday, April 24, 2017

Making Report Using Jasper Report Netbeans

This tutorial discuss about how to make a report. Before make a report in netbeans, make sure ireport plugin had been installed on your laptop. How to install Jasper Report can be read in my previous tutorial : How to install Jasper Report Plugin in Netbeans. JasperReport Library is open source report machine which most popular in the world. JasperReport was wrote on java leanguage and it capable to use data which  originated from all kinds data source and produce pixel document, perfect to be seen , printed or exported in various document format including HTML, PDF, Excel, OpenOffice and Word.

Oke, Let's I show you, how to make report using JasperReport.
First, we must make a database and table to display in report. This a database and table that I use to display in report :
I had made database whih named "absensi". Then I made table named "mahasiswa".
Contents of table mahasiswa in picture below.

Second, makes java project named "LearnReport" (remember without spacing)
1. Make java project


2. Make java file named "ExampleReport".

3.  Make form using JFrame Form and named "PrintReport".


4. Drag jButton on your form, then edit name became "Print Report" like picture below.

5. Next, we make new project with jasper report.
Fist, choose "Report Wizard" then next

Choose layout do you want, in this tuttorial I choose Coffe. 

Next, I fill File Name of file report. I named it "Report.jrxml" (.*jrxml must be included)

Next, we must be make a connector / data source. Fuction of data source are storing data to display in report.

Make sure that you choose "Database JDBC Connection"

Then click next, and fill some requirment of JDBC Connection. Make sure that you fill are same with picture that I make below. Click button "Test" to knowing whether the connection is success.

For display data to report you must select what table which you want to display. You can write with SQL script or you can choose Design Query and select table that you want.

I choose table "mahasiswa" then click OK

Automatically Query (SQL) filled with script that used to display table mahasiswa.

After that, appear columns that you choose in query script. Move columns from left to right with push button ">>".

No group, straight to click next.

Finally all had done, click Finish

6. Display of report that we made before is like picture below.
IReport,Jasper Report, Java, Netbeans, Laporan
 Click view to generate file .jrxml to .jasper ,and load data form datasource.
IReport,Jasper Report, Java, Netbeans, Laporan

7. Time to coding. Open your java file (ExampleReport.java), then write the code like here :


Then, open your java file (PrintReport.java)
Right click button "Print Report", choose Event --> Action --> actionPerformed. After that you write code like this:


Before that you must adding libraries  in the top of code (Before pulic class PrintReport). Libraries that we use are sql and jasper report.


8. Download plugin for JasperReport in Here
9. Enter your plugin to libary in netbeans (Right Click Libraries --> Add JAR/Folder --> Select File Jar.
10. Running your project, then after appear Form PrintReport, you push the button. Automatically appear report like picture in below.
IReport,Jasper Report, Java, Netbeans, Laporan

If you succesfull with my tutorial, your program surely can display a report.
Oke, thanks for visit my blog, meet again in next tutorial.

Afandi Nat
Afandi Nat

Seorang pemuda yang sedang belajar memanfaatkan dunia maya ke hal yang positif. Bukan anak Baperan dan senang bila diajak jalan2 menikmati pemandangan Alam (Apalagi diajaknya sama kamu...,,iya kamu :) )

No comments: