pentaho Report Designer 入门教程(三)
来源:互联网 发布:乐百视网络机顶盒 编辑:程序博客网 时间:2024/04/18 20:34
采用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 中文无法显示
- UDP穿透NAT Firewall原理
- PriorityQueue剖析
- 用户登录小程序
- 适配器模式(转)
- The SetStack Computer(stack) -uva 12096
- pentaho Report Designer 入门教程(三)
- class字节计算
- mybatis, mapper.xml常用配置
- 【Linux开发】Linux V4L2驱动架构解析与开发导引
- Floyd判圈算法
- 【J2SE】——初见Java
- 六大设计原则之里氏替换原则
- com/android/dx/command/Main : Unsupported major.minor version 52.0
- 深入浅出谈java修饰符