Pentaho Report Designer 入门教程(三)
来源:互联网 发布:2016年网络神曲 编辑:程序博客网 时间:2024/03/29 08:25
Pentaho Report Designer 入门教程(三)
采用Pentaho Report Designer5.1版本,也是最新的版本。
一、 安装和介绍
介绍部分内容略,首先安装jdk,并配置java相关环境变量,下载pentaho report并解压,直接运行即可。
二、 第一个示例
三、在Swing程序中集成
四、在j2ee程序中集成
Ø 新建web项目
Ø 编写ant脚本,编译运行项目
<?xml version="1.0"encoding="UTF-8" standalone="no"?>
<projectbasedir="."default="start_tomcat"name="Ch2WebApp">
<propertyname="webDir"value="war"/>
<propertyname="tomcat.home"value="D:/program/tomcat6"/>
<pathid="classpath">
<filesetdir="lib">
<includename="*.jar"/>
</fileset>
<filesetfile="${tomcat.home}/lib/servlet-api.jar"/>
</path>
<pathid="runtime_classpath">
<filesetdir="lib">
<includename="*.jar"/>
</fileset>
<dirsetdir="classes"/>
</path>
<targetname="compile">
<echomessage="compile"/>
<mkdirdir="classes"/>
<javacclasspathref="classpath"destdir="classes"srcdir="src"includeantruntime="on"fork="true"encoding="UTF-8"/>
</target>
<targetname="war"depends="compile">
<deletefile="chapter2.war"/>
<warbasedir="war"destfile="chapter2.war"webxml="war/WEB-INF/web.xml">
<classesdir="classes"/>
<zipfilesetdir="data"prefix="data"/>
<zipfilesetdir="lib"prefix="WEB-INF/lib"/>
</war>
<deletedir="${tomcat.home}/webapps/chapter2"/>
<deletefile="${tomcat.home}/webapps/chapter2.war"/>
<copyfile="chapter2.war"todir="${tomcat.home}/webapps"/>
</target>
<targetname="start_tomcat"depends="war">
<exectimeout="1000"dir="${tomcat.home}/bin"executable="${tomcat.home}/bin/shutdown.bat"/>
<sleepseconds="2"/>
<execdir="${tomcat.home}/bin"executable="${tomcat.home}/bin/startup.bat"/>
</target>
</project>
Ø 测试通过servlet 访问不同文件格式的报表
publicvoid init(ServletConfig config)throws ServletException {
ClassicEngineBoot.getInstance().start();
super.init(config);
}
protectedvoiddoGet(HttpServletRequest request,
HttpServletResponse response)throws ServletException, IOException {
try {
ResourceManager manager =new ResourceManager();
manager.registerDefaults();
String reportPath = "file:"
+ this.getServletContext().getRealPath(
"data/ch2_1.prpt");
Resource res =manager.createDirectly(newURL(reportPath),
MasterReport.class);
MasterReport report = (MasterReport)res.getResource();
// determine the output format and renderaccordingly
String outputFormat =request.getParameter("outputFormat");
if ("pdf".equals(outputFormat)) {
// render thepdf
response.setContentType("application/pdf");
PdfReportUtil.createPDF(report,response.getOutputStream());
} elseif ("xls".equals(outputFormat)) {
// render in excel
response.setContentType("application/vnd.ms-excel");
ExcelReportUtil.createXLS(report,response.getOutputStream());
} elseif ("rtf".equals(outputFormat)) {
// render inrtf
response.setContentType("application/rtf");
RTFReportUtil.createRTF(report,response.getOutputStream());
}
} catch (Exception e) {
e.printStackTrace();
}
super.doGet(request, response);
}
Ø jsp或html文件调用servlet
<body>
<h1>Example Application</h1>
<p>This is an exampleapplication demonstrating how to embed
Pentaho Reporting into yourweb application.</p>
<a href="report?outputFormat=pdf"target="black">Generate PDF Report </a><br/>
<a href="report?outputFormat=xls"target="black">Generate Excel Report</a><br/>
<a href="report?outputFormat=rtf"target="black">Generate RTF Report </a><br/>
</body>
- Pentaho Report Designer 入门教程(三)
- pentaho Report Designer 入门教程(三)
- Pentaho Report Designer 入门教程(一)
- Pentaho Report Designer 入门教程(二)
- pentaho Report Designer 入门教程(二)
- Pentaho Report Designer介绍
- Pentaho Report Designer 小结
- Pentaho Report Designer 发布报表设置
- 在项目中集成Pentaho Report Designer
- Pentaho Report Designer 隔行换色
- Pentaho Report Designer 源码分析过程
- pentaho report designer 5.01报表分组
- Pentaho Report Designer连接HSQLDB问题
- Pentaho Report Designer 教程(一)初识
- Pentaho Report Designer 隔行变色的设置
- Pentaho Report Designer 数据大于某值显示红色
- Pentaho Report Designer 教程(二)报表元素介绍
- Pentaho Report Designer 5.0.1 中文无法显示
- 自定义TabBar详解
- Ubuntu14下配置mysql的方法
- 设计模式笔记-代理模式
- Ubuntu terminator 多窗口终端的快捷键
- 2014年游戏行业概况
- Pentaho Report Designer 入门教程(三)
- Eclipse Coding Tips
- 在大学中获得全面的成长
- 在Cocos2d-X中创建一个场景
- 三级网络总结(对考三级网络的同学的建议)
- UTF_8与GB2312互转
- 深入理解javascript原型和闭包(15)——闭包
- 是不是应该坚持跟老师做项目
- 伪中介模式(5.5)