日期:2014-05-18  浏览次数:20676 次

jaspereport报表问题
用ireport做好报表编译好之后....

要怎样在jsp中调用.....在jsp中要能够查询之后生成报表...

要生成html   的....

能不能给个调用传值的例子....

网上找了半天都不行....各位大侠有自己做好的能运行的贴出来看看...谢谢

ireport   1.3.2

------解决方案--------------------
没用过,帮顶.
------解决方案--------------------
我刚好正在用JasperReport做报表,下面是我的代码:

<%@ page language= "java " pageEncoding= "UTF-8 "%>
<%@ page import= "net.sf.jasperreports.engine.* " %>
<%@ page import= "net.sf.jasperreports.engine.data.JRBeanCollectionDataSource " %>
<%@ page import= "net.sf.jasperreports.engine.export.* " %>
<%@ page import= "net.sf.jasperreports.engine.design.* " %>
<%@ page import= "net.sf.jasperreports.engine.xml.* " %>
<%@ page import= "net.sf.jasperreports.j2ee.servlets.* " %>
<%@ page import= "java.util.* " %>
<%
List list=(List)request.getAttribute( "list ");
String path=application.getRealPath( "/report/bphdfxreport.jrxml ");
//Load the sample report file from the XML file
//into the JasperDesign object.
JasperDesign design=JRXmlLoader.load(path);
//Compile the Report in Memory storing it in a JasperReport object
//now .jasper report file is created.
JasperReport report=JasperCompileManager.compileReport(design);
//Fill the report using the JRBeanCollectionDataSource passed
//a Hibernate query result set.
Map parameters = new HashMap();
parameters.put( "Title ", "MyReport ");
parameters.put( "name ", "freda ");
parameters.put( "hh ", "113 ");
parameters.put( "zdjh ", "3 ");
JasperPrint jasperPrint=JasperFillManager.fillReport(report,parameters,new JRBeanCollectionDataSource(list));
session.setAttribute(BaseHttpServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
// export
JRHtmlExporter exporter = new JRHtmlExporter();
session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "../servlets/image?image= ");
exporter.exportReport();
%>