Total members 11890 |It is currently Wed Apr 24, 2024 5:59 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Jasper Report example for library and print it to HTML.
java code
package ReportGen;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JFrame;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;

/**
*
* @author sami
*/


/**
*
* @author user
*/
public class ReportPanel extends JFrame {

/** Creates a new instance of BorrowBookPanel */
public ReportPanel(Connection connection,JFrame myMother)
{

setTitle("Reports");
myconn=connection;

setSize(500,500);



cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

dispose();
}
});
BBew.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

BorrBReport();
}
}); BS.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

BookSReport();
}
});
Me.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MemberReport();

}
});
setLayout(new FlowLayout());

add(BBew);
add(BS);
add(Me);
add(cancel);

}

public void BorrBReport()
{
String reportSource = "./reports/BorrowedBooks.jrxml";
String reportDest = "./reports/BorrowedBooks.html";

Map<String, Object> params = new HashMap<String, Object>();

params.put("reportTitle", "Borrowed Books");
params.put("author", "Casper");
params.put("startDate", (new java.util.Date()).toString());
try
{
JasperReport jasperReport =
JasperCompileManager.compileReport(reportSource);

// Make the driver class available.

JasperPrint jasperPrint =
JasperFillManager.fillReport(
jasperReport, params, myconn);

JasperExportManager.exportReportToHtmlFile(
jasperPrint, reportDest);

JasperViewer.viewReport(jasperPrint);
}
catch (JRException ex)
{
ex.printStackTrace();
}
}
public void MemberReport()
{
String reportSource = "./reports/Member.jrxml";
String reportDest = "./reports/Member.html";

Map<String, Object> params = new HashMap<String, Object>();

params.put("reportTitle", "Members");
params.put("author", "Casper");
params.put("startDate", (new java.util.Date()).toString());
try
{
JasperReport jasperReport =
JasperCompileManager.compileReport(reportSource);

// Make the driver class available.

JasperPrint jasperPrint =
JasperFillManager.fillReport(
jasperReport, params, myconn);

JasperExportManager.exportReportToHtmlFile(
jasperPrint, reportDest);

JasperViewer.viewReport(jasperPrint);
}

catch (JRException ex)
{
ex.printStackTrace();
}
}

public void BookSReport()
{
String reportSource = "./reports/BookStore.jrxml";
String reportDest = "./reports/BookStore.html";

Map<String, Object> params = new HashMap<String, Object>();

params.put("reportTitle", "Book Store");
params.put("author", "Casper");
params.put("startDate", (new java.util.Date()).toString());
try
{
JasperReport jasperReport =
JasperCompileManager.compileReport(reportSource);

// Make the driver class available.

JasperPrint jasperPrint =
JasperFillManager.fillReport(
jasperReport, params, myconn);

JasperExportManager.exportReportToHtmlFile(
jasperPrint, reportDest);

JasperViewer.viewReport(jasperPrint);
}

catch (JRException ex)
{
ex.printStackTrace();
}
}

private JButton BBew=new JButton("Borrowed Book");
private JButton BS=new JButton("Book Store");
private JButton Me=new JButton("Members ");

private JButton cancel=new JButton("Cancel");
private Connection myconn;


}


Used in :
finished-projects/library-database-management-system-project-t10813.html



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Jasper Report Java Usage Example
 Jasper report     -  
 Need Java program for display the CPU usage     -  
 crystal report     -  
 Crystal report     -  
 About Report Generation     -  
 How make a report using IReport on JSP?     -  
 dynamic crystal report generation     -  
 Can anybody give me a sample project report on mathematics f     -  
 Crystal report export to excel, page header issue asp.net     -  
 usage of ol tag     -  



Topic Tags

Java Reports






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com