在Web里面用Jasper导出Pdf、HTML、Excel,以及参数说明参考:ireport导出各种格式(pdf,excel,word,html,print)
在Web里面用Jasper导出Pdf、HTML、Excel,以及参数说明
参考:ireport导出各种格式(pdf,excel,word,html,print)的例子:
http://mingxiao2010.blog.163.com/blog/static/861904812010665366872/
说明:
at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:121)
at jasperreportsdemoapp.Main.main(Main.java:67)
..............
这个就是开始说的itext包不正确导致的参考下面的网站解决掉了,呵呵
参考:http://blogs.sun.com/geertjan/entry/itext_and_jasper_using_them
其中注意一下提示的错误NoClassDefFoundError,并非是说你没有添加相关的jar包到classpath,而极可能是版本不对,参阅下面:
Difference between ClassNotFoundException and NoClassDefFoundError
http://www.jroller.com/sjivan/entry/difference_between_classnotfoundexception_and_noclassdeffounderror
最后提一下,jasper现在使用需要辅助jar包的情况:
JasperReports Requirements
http://jasperforge.org/website/jasperreportswebsite/trunk/documentation.html?header=project&target=jasperreports
w
eb中应用jasperreport:
http://923080512.iteye.com/blog/1396484
在web中使用jasperreport 要导入的包:
jasperreports-4.5.0.jar
js_activation-1.1.jar
iText-2.1.7.jar
iTextAsian.jar
groovy-all-1.7.5.jar
commons-beanutils-1.8.2.jar
commons-digester-1.7.jar
commons-collections-3.2.1.jar
poi-3.7-20101029.jar
方法1:
byte[] b = null ; response.setContentType("application/pdf"); response.setHeader("Content-Disposition","filename="+ java.net.URLEncoder.encode("Syz_PDF"+new SimpleDateFormat("yyyyMMddHHmmssSS").format(new Date()), "UTF-8") + ".PDF"); //转换成pdf,如果是html,转换后直接response.sendRedirect() b = JasperRunManager.runReportToPdf(filename, map, datasource); out.write(b); out.flush(); out.close();