iReport 报表在应用程序中的应用代码!~!!!

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

下面的代码是我在用ireport做报表,应用在应用程序中的代码,应用程序可以引用这个类,完成报表打印

预览:有问题请联系我!!!一起探讨!

import dori.jasper.engine.*;

import dori.jasper.engine.util.*;

import java.sql.*;

import java.util.*;

import dori.jasper.engine.JasperReport;

import java.util.Date;

import java.text.SimpleDateFormat;

import dori.jasper.view.*;

import org.apache.commons.logging.LogFactory;

import com.lowagie.text.DocumentException;

import com.lowagie.text.*;

import dori.jasper.engine.design.*;

import org.apache.commons.digester.Digester;

import org.apache.commons.beanutils.BeanUtils;

public class myreport

{

public void reportName(String strBbmc)

{

JRResultSetDataSource jrds = null;

JasperPrint jasperPrint = null;

Map reportParams = new HashMap();

ResultSet rs = null;

Connection con = null;

Statement stmt = null;

String sql = "select * from bbmc";

try

{

//动态获取

JasperDesign jasperDesign = JasperManager.loadXmlDesign("./bbmc.jrxml");

JasperReport jasperreport = JasperManager.compileReport(jasperDesign);

//建立连接

ConnectionpoolManager mgr = new ConnectionpoolManager();

mgr.setMonitorThread(520);

mgr.addAlias("jdbcConnecpool","com.microsoft.jdbc.sqlserver.SQLServerDriver","jdbc:microsoft:sqlserver://192.168.45.233:1433;DatabaseName = ysgl ","sa","sa",10,300,520,30,false);

con = DriverManager.getConnection(ConnectionPoolManager.URL_PREFIX+ConnectionPoolManager.getPoolName(),null,null);

stmt = con.creatStatement();

rs = stmt.executeQuery(sql);

jrds = new JRResultSetDataSource(rs);

jasperPrint = JasperFillManager.fillReport(jasperReport,reportParams,jrds);

//调出JasperViewer进行打印预览

JasperViewer.viewReport(jasperPrint);

}

catch(ClassNotFoundException ee)

{

ee.printStackTrace();

}

catch(SQLException ex)

{

ex.pritStackTrace;

}

catch(JRException e)

{

e.getMessage();

}

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航