这东西捯饬了好长时间都不成功,还好又仔细找了官网入门资料,才做出一个简单的东西。

事先需要安装Tomcat,具体步骤参考birt官网教程,www.eclipse.org/birt/documentation/integrating/viewer-setup.php

官方提供的代码:

import java.io.IOException;

import org.eclipse.birt.core.framework.Platform;

import org.eclipse.birt.report.model.api.CellHandle;

import org.eclipse.birt.report.model.api.DesignConfig;

import org.eclipse.birt.report.model.api.DesignElementHandle;

import org.eclipse.birt.report.model.api.ElementFactory;

import org.eclipse.birt.report.model.api.GridHandle;

import org.eclipse.birt.report.model.api.IDesignEngine;

import org.eclipse.birt.report.model.api.IDesignEngineFactory;

import org.eclipse.birt.report.model.api.ImageHandle;

import org.eclipse.birt.report.model.api.LabelHandle;

import org.eclipse.birt.report.model.api.ReportDesignHandle;

import org.eclipse.birt.report.model.api.RowHandle;

import org.eclipse.birt.report.model.api.SessionHandle;

import org.eclipse.birt.report.model.api.activity.SemanticException;

import com.ibm.icu.util.ULocale;

/**

* Simple BIRT Design Engine API (DEAPI) demo.

*/

public class SimpleCreate

{

public static void main( String[] args )

{

try

{

buildReport( );

}

catch( IOException e )

{

e.printStackTrace();

}

catch( SemanticException e )

{

e.printStackTrace();

}

}

// This method shows how to build a very simple BIRT report with a

// minimal set of content: a simple grid with an image and a label.

static void buildReport() throws IOException, SemanticException

{

// Create a session handle. This is used to manage all open designs.

// Your app need create the session only once.

//Configure the Engine and start the Platform

DesignConfig config = new DesignConfig( );//org.eclipse.birt.report.model.api.DesignConfig

config.setProperty("BIRT_HOME", "D:/birt-runtime-4_5_0/ReportEngine");

IDesignEngine engine = null;

try

{

Platform.startup( config );

IDesignEngineFactory factory = (IDesignEngineFactory) Platform.createFactoryObject( IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );

engine = factory.createDesignEngine( config );

}

catch( Exception ex )

{

ex.printStackTrace();

}

SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;

// Create a new report design.

ReportDesignHandle design = session.createDesign( );

// The element factory creates instances of the various BIRT elements.

ElementFactory efactory = design.getElementFactory( );

// Create a simple master page that describes how the report will appear when printed.

//

// Note: The report will fail to load in the BIRT designer unless you create a master page.

DesignElementHandle element = efactory.newSimpleMasterPage( "Page Master" );

design.getMasterPages( ).add( element );

// Create a grid and add it to the "body" slot of the report design.

GridHandle grid = efactory.newGridItem( null, 2 /* cols */, 1 /* row */ );

design.getBody( ).add( grid );

// Note: Set the table width to 100% to prevent the label

// from appearing too narrow in the layout view.

grid.setWidth( "100%" );

// Get the first row.

RowHandle row = (RowHandle) grid.getRows( ).get( 0 );

// Create an image and add it to the first cell.

ImageHandle image = efactory.newImage( null );

CellHandle cell = (CellHandle) row.getCells( ).get( 0 );

cell.getContent( ).add( image );

image.setURL( "\"urlofimage\"" );

// Create a label and add it to the second cell.

LabelHandle label = efactory.newLabel( null );

cell = (CellHandle) row.getCells( ).get( 1 );

cell.getContent( ).add( label );

label.setText( "Hello, world!" );

// Save the design and close it.

design.saveAs( "d:/Program Files/apache-tomcat-8.5.2/webapps/birt/work.rptdesign" ); //将报表文件放在Tomcat目录下以便显示

design.close( );

System.out.println("Finished");

// We're done!

}

}

运行代码之前,需要把birt-runtime中/ReportEngine/lib文件夹下的所有jar包导入。

程序成功运行后会在Tomcat的birt目录下新建work.rptdesign报表文件,浏览器登陆http://localhost:8080/birt/frameset?__report=work.rptdesign即可显示结果。

源码具体含义可参考官网API。

birt java_BIRT的Java实现相关推荐

  1. 免费开源JAVA报表工具对比 BIRT报表VS润乾报表之初体验

    前一段时间,被导师安排对报表开发工具做调研,之后就一度泡在各大博客.论坛里,尽可能全面的搜集了几款报表工具的优缺点,攒成了<java报表工具报表软件选型经验总结分享>.不过大多都是直接抄的 ...

  2. birt java api_BIRT使用API进行简单部署

    在网上查了下BIRT的文章,不是很多.而且讲述的也不是十分全面.还是得自己琢磨啊. 刚实验好,贴上来分享一下共同交流.希望也能帮助到对API部署还困惑的人. 做这个纯粹是看官网上的例子,还有好多疑点, ...

  3. java birt project_Eclipse BIRT问题解决汇总(不断更新)

    1.复合JavaBean数据源 1.1说明 在使用Eclipse BIRT进行报表开发时,会遇到使用复合型的JavaBean作为数据源的情况,例如Contact对象有一个Address类型的对应add ...

  4. java+birt+实例_BIRT简单实例

    以前很少做报表, 项目中的有报表的需求,暂时还只能用了一些简单的CSS,JS,控制,不过功能很有限. 收集一下资料.做了一个简单的, 但应用到项目中,还要断续学习一下. BIRT是一个Eclipse- ...

  5. birt java api_「Birt」birt api生成报表 | 学步园

    public class PDFReportServiceAccess { /** */ /** 初始化的状态 */ protected static boolean initStatus = fal ...

  6. 常用的6款Java开源报表制作工具

    本文为大家推荐6款常用的Java开源报表制作工具,供开发者学习.参考. 1.Aspose.Cells for JasperReports 一个基于Java的开源报表工具,它可以在Java环境下像其他I ...

  7. 拖拖拽拽画JAVA报表?

    许多Java报表开发工具,特别是有点BI色彩的产品都会向用户宣称产品简单易用,只要鼠标拖拽几下就能画好报表了,甚至能让业务人员随心所欲地制作各种统计报表. Java报表开发居然已经变得这么轻松简单了? ...

  8. 这些个JAVA开源工具(那是相当地多啊)

    OpenCms [Java开源 CMS系统] OpenCms是一个J2EE的产品,它是用Java写成的.它和Tomcat捆绑在一起.但是也能够使用ATG Dynamo.WebLogic和WebSphe ...

  9. java实现续打功能_浅谈报表工具的打印方案

    报表工具除了基本的绘制报表,完成数据呈现(也就是让终端用户能看到报表),打印也是报表的基本功能之一. 当前报表工具很多,可以按地域.开闭源等划分,包括有杰表.水晶.Style Report.birt. ...

最新文章

  1. GLIBC 升级安装与 SCL 知识盲区
  2. 失手打死请自己吃饭的酒友 嫌疑人在深圳落网
  3. centos7 安装oracle jdk 与openjdk 实现切换
  4. COM_TEXT_TIMESTAMP_SET
  5. cesium鼠标控制键盘_Cesium中级教程3 - Camera - 相机(摄像机)
  6. Android面试,与Service交互方式
  7. SVM(三)—Kernels(核函数)
  8. Kafka权威指南-学习笔记---第四章
  9. android 默认分辨率是多少合适,Bluestacks分辨率修改多少合适
  10. 深圳市城中村有哪些,在哪里?请知道的朋友告知,谢谢了!
  11. python异步和进程_浅谈python异步IO,同步IO,线程与进程~
  12. Qt应用程序开发九:上传文件
  13. 北鲲云超算平台助力国产芯片设计
  14. Android app 录音回音消除两种方法
  15. Jqury基础大汇总来啦~
  16. 水泵泵宝显示下池缺水但是水池水很满_水泵控制器不能自动怎么办 显示下池缺水如何处...
  17. 【java并发编程实践】源码
  18. 【更新】python写的sogou代理全网加速器,特别适合于教育网(稍改动)
  19. java毕业设计小微企业人事管理系统源码+lw文档+mybatis+系统+mysql数据库+调试
  20. 笔记本关键字:IEEE1394接口

热门文章

  1. 昆仑万维拟收购音频社交应用StarMaker,全球超5000万活跃用户,2020年营收6.2亿
  2. 退订招商银行广告邮件那些事
  3. 强化学习——百度飞桨paddlepaddle parl
  4. Python调用百度地图绘制热力图密钥问题
  5. oracle flashback database,Oracle Flashback Database
  6. 另一个伊甸 回生副本奖励汇总
  7. Android输入系统(三)——InputReader的加工类型和InputDispatcher的分发过程(基于Android 13)
  8. (转载)Oracle的结构体系的抽象
  9. linux服务器(云服务器)缓存占用过大问题解决
  10. 每天回顾linux命令(whereis)