- 浏览: 381976 次
- 性别:
- 来自: 南京
文章分类
最新评论
-
793059909:
scala> def count(x:Double,n: ...
快学Scala习题解答—第二章 控制结构和函数 -
793059909:
scala> def countdown(n:Int){ ...
快学Scala习题解答—第二章 控制结构和函数 -
daquan198163:
可是奇慢无比啊,切换个页签得等一分钟啊!!!!!!!!
误会ZK Studio了!Sorry,Sorry! -
rmn190:
受教了, 今天我第一天遇到这个问题, 以前没想到fmt标签还跟 ...
JSP中的国际化(转) -
suu:
都是栈里的拷贝 这句话让我从一头雾水到豁然开朗 谢谢了.
争论话题:Java传值还是传引用?
Web Application Sample
This sample Web application was created to show that the JasperReports library is perfect for using in Web environment.
这个web示例说明了JasperReports能够胜任web环境开发。
You can see here how to generate reports on the server side using Java Server Pages or Java Servlets and how to view them on the client side, either by using Java Applets or by exporting them to PDF, HTML, XLS or RTF format.
你能看见如何在服务端用jsp或servlet来发布报表和如何在客户端查看,可以使用applets或pdf,html,xsl,ptf格式都可以。
Attention! Try the application menu options in the same order in which they are displayed. Otherwise, important steps involved when working with the JasperReports library might get skipped and error messages will be displayed, instead of the expected output.
注意!按照标签显示的顺序来执行他们。否则,关键步骤被跳过的话可能就会报错,而不会出现期望的结果了。
JRXML Report Design Compilation
Note that in the majority of cases, the JRXML report template compilation process is an application build-time process and not a runtime process.
注意了,在多数情况下,JRXML格式的报表模板的编译都是在应用程序的创建时候进行的而不是在运行时进行的。
Normally, report templates have to be compiled only once, just like we compile Java source files and then we deploy them with the application. If the report templates are not dynamic, there is no point on recompiling them at runtime. Report definitions are static and only the data supplied to them is different with every report filling operation.
通常情况下,报表模板只需要编译一次,就像我们编译java源代码一样。然后我们把它们发布到应用程序上去。如果报表模板不是动态的,在运行时他们不会再编译一次了。报表时静态的,而变得只是填充的数据。
However, sometimes applications do require runtime report template compilation, so here you can see how this can be achieved in Web environment.
但是,有时候应用程序需要在运行时编译报表模板,所以这里你能看见在web环境下是如何完成编译的。
The following example performs the compilation of the WebappReport.jrxml file and produces the WebappReport.jasper file.
下面的例子编译WebappReport.jrxml文件并产生WebappReport.jasper文件。
- <%@ page import="net.sf.jasperreports.engine.*,net.sf.jasperreports.engine.util.JRProperties" %>
- <%
- JasperCompileManager.compileReportToFile(application.getRealPath("/reports/WebappReport.jrxml"));
- %>
Filling Reports with Data
The servlet and the JSP below both show how a compiled report template (.jasper file) could be filled with data. They place the resulting net.sf.jasperreports.engine.JasperPrint object onto the HTTP session from where subsequent report viewing and exporting servlets and JSPs in this sample application will reuse it.
下面的servlet和jsp都显示了如何向编译过的报表模板里填充数据。填充数据后会获得net.sf.jasperreports.engine.JasperPrint 类型的结果。将其放到HTTP session里。在后面的viewing和exporting里还会用到。
- <%@ page import="datasource.*" %>
- <%@ page import="net.sf.jasperreports.engine.*" %>
- <%@ page import="net.sf.jasperreports.engine.util.*" %>
- <%@ page import="net.sf.jasperreports.engine.export.*" %>
- <%@ page import="net.sf.jasperreports.j2ee.servlets.*" %>
- <%@ page import="java.util.*" %>
- <%@ page import="java.io.*" %>
- <%
- String reportFileName = application.getRealPath("/reports/WebappReport.jasper");
- File reportFile = new File(reportFileName);
- if (!reportFile.exists())
- throw new JRRuntimeException("File WebappReport.jasper not found. The report design must be compiled first.");
- Map parameters = new HashMap();
- parameters.put("ReportTitle", "Address Report");
- parameters.put("BaseDir", reportFile.getParentFile());
- JasperPrint jasperPrint =
- JasperFillManager.fillReport(
- reportFileName,
- parameters,
- new WebappDataSource()
- );
- session.setAttribute(BaseHttpServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
- %>
Exporting Reports to Other Formats Like PDF, HTML, XLS and RTF
Before testing the exporting functionality exposed on this page, the report has to be already filled using the fill report menu option so that the generated net.sf.jasperreports.engine.JasperPrint be available on the HTTP session for exporting.
在测试将报表显示到页面上之前,需要先fill report以得到net.sf.jasperreports.engine.JasperPrint并将其保存到HTTP session中。
- <%@ page import="datasource.*" %>
- <%@ page import="net.sf.jasperreports.engine.*" %>
- <%@ page import="net.sf.jasperreports.engine.util.*" %>
- <%@ page import="net.sf.jasperreports.engine.export.*" %>
- <%@ page import="net.sf.jasperreports.j2ee.servlets.*" %>
- <%@ page import="java.util.*" %>
- <%@ page import="java.io.*" %>
- <%
- File reportFile = new File(application.getRealPath("/reports/WebappReport.jasper"));
- if (!reportFile.exists())
- throw new JRRuntimeException("File WebappReport.jasper not found. The report design must be compiled first.");
- JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
- Map parameters = new HashMap();
- parameters.put("ReportTitle", "Address Report");
- parameters.put("BaseDir", reportFile.getParentFile());
- JasperPrint jasperPrint =
- JasperFillManager.fillReport(
- jasperReport,
- parameters,
- new WebappDataSource()
- );
- JRHtmlExporter exporter = new JRHtmlExporter();
- StringBuffer sbuffer = new StringBuffer();
- 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();
- %>
发表评论
-
欢迎关注微信公众账号PigCode
2014-03-25 21:02 867开通了微信公众账号,欢迎大家关注: PigCode 不定 ... -
[FAQ]为什么引入lambda表达式
2013-07-02 20:54 1550Lambda表达式(闭包)在很多现代化的编程语言中很常见。在 ... -
[FAQ]什么是lambda表达式
2013-07-01 23:01 1460在一般数学计算中,lambda表达式就 ... -
Java&Scala比较---设计模式(Singleton)
2013-03-31 11:56 1279单例模式在Scala中就是一个默认实现的模式。 对于Java中 ... -
榨干Hello World:J2SE篇
2010-07-26 23:43 0昨天一时兴起想起这个问题(我好像一般都是一时兴起才会写 ... -
使用Ant部署项目细节问题及解决办法
2009-04-23 22:57 4063说原创也谈不上, ... -
重构?测试?TDD?Ant?
2009-04-11 23:56 2846很意外的,今天花 ... -
《重构:改善既有的代码设计》笔记
2009-03-21 15:30 0现在越看自己的代码越感觉恶心,感觉写得太糟糕了,根本见 ... -
5分钟搞定Schema
2008-12-18 21:38 3256事先声明:搞定不是精通,只是能够运用! 其实schema很简单 ... -
JNDI学习
2008-12-02 17:50 0之前接触过一点E ... -
Struts2源码研究1
2008-08-21 17:30 4970看struts2一周,就搞定了一个程序,郁闷。还有源码里的一个 ... -
将Struts2+EJB3程序从eclipse转移到Intellij Idea上
2008-08-20 16:12 2146之前写了个Struts2+EJB3的入门程序,好不容易搞 ... -
坎坷的Struts2+EJB3入门程序
2008-08-15 22:24 5053最近在看Struts2和EJB3,出于好奇,就想试试用部署在t ... -
集成jdk到editplus(转)
2008-04-11 21:11 1615对于像我这样的java新手,写java程序用edit ... -
Intellij idea性能优化
2008-03-24 12:54 9098-Xms256m -Xmx384m -XX:MaxPermSi ... -
Struts meets Swing 1 (翻译)
2008-03-13 13:49 2058原文:http://javaboutique.internet ... -
使用Maven2快速创建项目(转)
2008-01-30 16:33 13015源地址:http://www.intellij.org.cn/ ... -
什么是Spring(转)
2008-01-16 13:00 1641最近研究Spring,她包含 ... -
JSP中的国际化(转)
2008-01-09 09:17 10307地区确定和本地化 设计多语言 web 应用程序时,您必须首先决 ... -
Intellij IDEA的部署问题。。。
2008-01-03 17:22 5283在网上偶尔都能看到说Intellij IDEA是如何的好 ...
相关推荐
JasperReports 在web中的应用JasperReports 在web中的应用JasperReports 在web中的应用JasperReports 在web中的应用
iReport+jasperReports开发java Application报表
JasperReports-Server-Web-Services-Guide.pdf
jasperreports-flash来实现web客户端打印的功能,避免了applet客户端打印在客户端安装jre的限制。jasperreports-flash只需要求客户端有能浏览swf文件的flash player就行了。可以根据自己的需求修改example.mxml文件...
iReport+jasperReports 制作WEB报表pdf格式,初学JAVA报表很有用
java ireport,ireport和jasperReports 制作web报表,
Jasperreports Jasperreports Jasperreports Jasperreports
jasperreports-6.11.0.jar jasperreports jasperreports
jasperreports,jasperreports,jasperreports,jasperreports,jasperreports,jasperreports,jasperreports,jasperreports,jasperreports
JasperReports is a content-rendering library, not a standalone application. It cannot run on its own and must be embedded in another client- or server-side Java application. JasperReports is a pure ...
commons-beanutils-1.7.0.jar;commons-collections-3.2.1.jar;commons-digester-2.1.jar;commons-logging-1.1.1.jar;itext-asian.jar;itextpdf-5.5.8.jar;jasperreports-6.1.1.jar;...jasperreports-javaflow-6.1.1.jar
jasperreports-6.1.0下载
jasperreports-5.6.0 api
用ireport关联web时,用到的jasperreports-6.0.0的jar包
JasperReports 3.6 Development Cookbook
jasperreports 教程
jasperreports-4.0.2.jar
jasperreports-6.16.0.jar
jasperreports-flash来实现web客户端打印的功能,避免了applet客户端打印在客户端安装jre的限制。jasperreports-flash只需要求客户端有能浏览swf文件的flash player就行了。可以根据自己的需求修改example.mxml文件...