Search This Blog

Friday, January 29, 2010

Jasper iReport

>> Download iReport
>> Set Data Source Connection
>> Take table and select report style
>> Execute The report
>> Save that ".jrxml" file in any location.
>> use related jar file to compile

Java Program

package com.abi;

import javax.swing.*;

import java.sql.Connection;
import java.sql.DriverManager;

import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.design.*;

public class MyiReportViewer extends JFrame
{

public MyiReportViewer ( )
{

}

public static void main ( String args[] )
{

MyiReportViewer viewer = new MyiReportViewer ();
try
{

Class.forName ( "com.mysql.jdbc.Driver" );
Connection con = DriverManager.getConnection ( "jdbc:mysql://localhost/test", "root", "root" );

JasperDesign jasperDesign = JasperManager.loadXmlDesign("E:/drvijay/IReport/First.jrxml");
JasperReport jasperReport = JasperManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperManager.fillReport(jasperReport, null, con);
JasperExportManager.exportReportToHtmlFile(jasperPrint, "E:/drvijay/IReport/First.html" );
//JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream );
System.out.println ( "success" );
}

catch ( Exception sqle )
{
sqle.printStackTrace ();
}

}
}

No comments:

Hit Counter


View My Stats