BIRT报表
1.概述
网站: http://www.eclipse.org/birt/phoenix/
BIRT报表 拥有和Dreamweaver一般的操作界面,可以像画table一样画报表,生成图片,导出Excel,html分页样样齐全,样式和script设置简单,貌似还有OLAP导航功能,JasperReport注定要被打入冷宫了。
特别留意,SpringSide里仿照Spring集成JasperReport的做法,集成了Birt View。
另外特别Demo了把查询语句统一写在SaleReportManager里,对查询语句综合处理与重用,而不是默认的在每个模版文件里面写SQL。
学习资料:
1.Birt的IBM DW的中文教程:http://www-128.ibm.com/developerworks/cn/opensource/os-ecl-birt/,
2.最权威、详细的莫过于birt 官方文档
3.难得的比较全面的 BIRT 中文指南
4.Flash Demo
2.部署BIRT2.1
2.1. 拷贝文件
将/plugins, /configuration两个目录复制到webapp 根目录, 将lib复制到webapp/WEB-INF/lib
2.2. 瘦身
Birt实在太过庞大,如果将以上三个目录全拷的话几十M.因此,可以参考SS里对/lib/birt 和 webapp/plugins目录反复试验后的精简。
另外,/lib和/plugins有好多jar是重复的,只要在编译时把jar 从一个目录copy过去就行。又要注意两个目录里相同的jar的命名并不相同,而/plugins里面的文件名很严格,可参考build.xml里的这段复制命令
<copy file="lib/birt/com.ibm.icu-3.4.4.1.jar" tofile="${web.dir}/plugins/com.ibm.icu_3.4.4.1.jar"/>
<copy file="lib/birt/js-2.1.jar" tofile="${web.dir}/plugins/org.mozilla.rhino/lib/js.jar"/>
<copy file="lib/birt/chartengineapi-2.1.jar" tofile="${web.dir}/plugins/org.eclipse.birt.chart.engine_2.1.0.N20060628-1351.jar"/>
<copy todir="${web.dir}/plugins">
<fileset dir="lib/birt">
<include name="org.eclipse.emf.*"/>
</fileset>
</copy>
3.将spring与birt集成在一起
3.1 why not 说明
3.1.1 为什么没有使用 birt report viewer
BIRT Report Viewer 貌似做得很周到,提供如浏览,打印,export to CSV ,过滤参数的传入等一系列的快速操作.
然而细心思考过,这个viewer还是存在不少问题:
如不适用的报表传入参数方式(无输入验证,无日期控件);代码复杂,可扩展性差......
发现不少功能形同虚设,所以决心抛弃.
3.1.2 为什么不在.rptdesign里写sql
往往实际项目的业务总是复杂的,不希望将复杂的逻辑通过几个简单的参数传入拼凑sql来实现,再说这样调试sql也是一件麻烦的事情,也不利于SQL管理
所以我们提倡 将查询的商业逻辑放回java Manager类,然后designer负责设计数据如何排列。这样子更适和实际项目.
3.2 自己实现的BirtReportsView的原理
实现Spring MVC的View,关键是重载它的protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) 函数
3.2.1 创建 EngineConfig 与 ReportEngine 实例
public class BirtReportsView extends AbstractUrlBasedView {
private String engineHome;
private ReportEngine engine;
public BirtReportsView() {
engineHome = System.getProperty("bookstore.root"); //engine home
EngineConfig birtConfig = new EngineConfig();
birtConfig.setEngineHome(engineHome);
engine = new ReportEngine(birtConfig);
}
}
3.2.2 设定报表文件
public void openReportDesign(String filePath) throws IOException, EngineException {
File reportFilte = new File(engineHome + "/" + filePath);
IReportRunnable design = engine.openReportDesign(reportFilte.getAbsolutePath());
task = engine.createRunAndRenderTask(design);
}
3.2.3 配置 htmlrendercontext
private String scriptableJOName = "dsFactory"; //dsFactory 自由定义,主要在rptdesign中调用
private String imageDirectory = "/report/images";
private String baseImageUrl = "images";
private void run(OutputStream outputStream) throws EngineException {
HTMLRenderContext renderContext = new HTMLRenderContext();
//chart 生成图片目录
renderContext.setImageDirectory(this.engineHome + "/" + imageDirectory);
//web页面浏览 base url
renderContext.setBaseImageURL(baseImageUrl);
HashMap contextMap = new HashMap();
contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext);
task.setAppContext(contextMap);
BirtDataSourceObject birtDataSourceObject = new BirtDataSourceObject();
HTMLRenderOption options = new HTMLRenderOption();
birtDataSourceObject.setResultList(resultList);
options.setOutputStream(outputStream);
task.setRenderOption(options);
//增加api级别的java对象,以方便报表中调用获取报表数据
task.addScriptableJavaObject (scriptableJOName, birtDataSourceObject);
task.run();
}
相关文章:
1.BIRT and POJOs as datasources example
2.详细的 Report Engine API 请见[官方 ]
3.3 Birt View的使用
见SaleReprontController.
public ModelAndView view(HttpServletRequest request, HttpServletResponse response) throws Exception {
String status = request.getParameter("status");
String beginDate = request.getParameter("beginDate");
String endDate = request.getParameter("endDate");
List bookList = saleReportManager.findBooksByReportParam(status,
DateUtil.parse(beginDate, "yyyy-M-d"), DateUtil.parse(endDate, "yyyy-M-d"));
BirtReportView view = new BirtReportView();
view.openReportDesign("/report/sale_report.rptdesign");
view.putModel(bookList);
return new ModelAndView(view);
}
分享到:
相关推荐
Birt报表注意Birt报表注意Birt报表注意Birt报表注意Birt报表注意Birt报表注意Birt报表注意Birt报表注意Birt报表注意
BIRT报表中文开发手册 PDF版本 BIRT Business Intelligence and Reporting Tools 是为 Web 应用程序开发的基于 Eclipse 的开源报表系统 特别之处在于它是以 Java 和 JavaEE 为基础 BIRT 有两个主要组件:基于 ...
birt报表合并以及表头锁定功能的实现。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
birt报表详细中文文档,html格式,很详细
birt报表的页面显示汉化资源文件及汉化过程说明,就是替换birt原有jar包中的英语资源文件为中文资源文件
Birt报表操作手册,有chart图,导出excel chart图显示
birt报表资料_珍藏: BIRT报表应用预研报告-0719.doc Birt使用经验谈chart2006.04.11.doc Birt使用小结.doc Birt学习经历.doc
birt报表的部署(对birt-eclipse开发的报表文件进行部署)!!!
该PPT主要是介绍了BIRT报表开发工具的基本知识和基本的使用方法,可以很好的帮助除此使用的新手来了解BIRT。
Birt报表开发手册,适用于birt 2.1.3,里面有很详细的开发说明。
Birt报表工具设计指南,图示介绍使用方法。
Birt 报表参数的使用,birt中参数的传入,使用.
birt报表开发初学者开发的学习视频,用于java web 开发报表
关于birt报表参数的使用 使用说明 具体实例
如何构建Birt报表应用程序,里面对构建birt报表应用程序有极详细的介绍
制作的birt报表实例,常用报表制作 维度 cube 脚本使用 动态参数传递
BIRT报表开发教程,非常详细的教程!包含各种类型的基础报表,交叉表等!
个人整理的BIRT报表学习手册,希望能帮助到大家。
Birt 报表的相关源码,共享给大家。 有了它可以对viewer做二次开发。
BIRT 报表 RCP Report Viewer 找了好久没有找到关于 BIRT 集成到RCP中的文章,现在先发两个例子先,详细待日后补充: Example of using the Report Viewer in an RCP application 见附件: