这个方法直接放到rcp下运行不了,几天过去才发现是个多么愚蠢的错误:在plugin.xml的dependiences添加org.eclipse.birt.report.viewer, org.eclipse.birt.core, org.eclipse.birt.report.engine, org.eclipse.birt.report.model等你需要的所有包后记得在自己的run--->configure-->plug-ins 里面把所有的birt都打上勾,否则运行会出错的
1,用birt设计rptdesign文件
(1)下载 birt framwork plugin放到eclipse目录下
(2)创建一个报表工程并制作一个报表(即rptdesign文件)
2,安装birt engine
下载 birt runtime 到任意目录,
3,创建一个java project 设置build 属性,使之包含birt 的core和report.engine,并把Report engine目录下的jar加到jar属性中
工程代码如下,其中几个路径根据自己配置设置:
import java.util.HashMap;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLRenderContext;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.ReportEngine;
public class ExecuteReport {
static void executeReport() throws EngineException
{
//Engine Configuration - set and get temp dir, BIRT home, Servlet context
EngineConfig config = new EngineConfig();
config.setEngineHome( "C:/birtruntime/birt-runtime-2_0_0/Report Engine" );
//Create the report engine
ReportEngine engine = new ReportEngine( config );
//Open a report design - use design to modify design, retrieve embedded images etc.
IReportRunnable design = engine.openReportDesign("D:/LiuYanbin/working/TestBIRT/customers.rptdesign");
//Create task to run the report - use the task to execute and run the report,
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
//Set Render context to handle url and image locataions
HTMLRenderContext renderContext = new HTMLRenderContext();
renderContext.setImageDirectory("image");
HashMap contextMap = new HashMap();
contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext );
task.setAppContext( contextMap );
//Set rendering options - such as file or stream output,
//output format, whether it is embeddable, etc
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFileName("D:/LiuYanbin/working/TestBIRT/customers.html");
options.setOutputFormat("html");
task.setRenderOption(options);
//run the report and destroy the engine
task.run();
engine.destroy();
}
/**
* @param args
*/
public static void main(String[] args) {
try
{
executeReport( );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
}
然后运行就可以看到生成的html文件了
分享到:
相关推荐
eclipse plugin 开发者帮助api文档
maven-javadoc-plugin 插件 解决中文乱码 和注解 时间问题, 包括eclipse.ini设置、pom.xml设置、maven build GBK设置、eclipse注释设置、eclipse注释模版(可导入)。
SCM API Plugin 0.2 hpi Build To build the plugin locally: mvn clean verify
maven-plugin-api-3.0.jar
包含翻译后的API文档:spring-plugin-core-2.0.0.RELEASE-javadoc-API文档-中文(简体)版.zip; Maven坐标:org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE; 标签:spring、core、plugin、spring...
赠送jar包:struts2-json-plugin-2.3.24.jar; 赠送原API文档:struts2-json-plugin-2.3.24-javadoc.jar; 赠送源代码:struts2-json-plugin-2.3.24-sources.jar; 赠送Maven依赖信息文件:struts2-json-plugin-...
包含翻译后的API文档:spring-plugin-metadata-2.0.0.RELEASE-javadoc-API文档-中文(简体)版.zip; Maven坐标:org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE; 标签:spring、metadata、plugin...
赠送jar包:jfinal-mail-plugin-3.0.jar; 赠送原API文档:jfinal-mail-plugin-3.0-javadoc.jar; 赠送源代码:jfinal-mail-plugin-3.0-sources.jar; 赠送Maven依赖信息文件:jfinal-mail-plugin-3.0.pom; 包含...
包含翻译后的API文档:spring-plugin-metadata-1.2.0.RELEASE-javadoc-API文档-中文(简体)-英语-对照版.zip 对应Maven信息:groupId:org.springframework.plugin,artifactId:spring-plugin-metadata,version:...
appengine-maven-plugin 支持App Engine开发人员的Maven插件。 在我们的官方《使用Apache Maven》文档站点上可以找到针对用户的更全面的文档。 Apache Maven是一个软件项目管理和理解工具。 它能够构建战争文件以...
birt-plugin,将birt集成到pentaho平台 集成方法参考http://blog.csdn.net/gaoyusi4964238/archive/2010/10/22/5958629.aspx
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,...
constraintscala.zip,约束萨拉
使用Unreal Engine 开发车辆组装,碰撞,模拟的插件的细节技术
包含翻译后的API文档:spring-plugin-metadata-2.0.0.RELEASE-javadoc-API文档-中文(简体)-英语-对照版.zip; Maven坐标:org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE; 标签:spring、...
Apache HttpComponents Client 4.x API Plugin Bootstrap 4 API Plugin Bootstrap 5 API bouncycastle API Branch API Build Timeout Caffeine API Plugin Checks API plugin Command Agent Launcher Plugin ...
包含翻译后的API文档:spring-plugin-core-1.2.0.RELEASE-javadoc-API文档-中文(简体)版.zip 对应Maven信息:groupId:org.springframework.plugin,artifactId:spring-plugin-core,version:1.2.0.RELEASE 使用...
包含翻译后的API文档:spring-plugin-metadata-1.2.0.RELEASE-javadoc-API文档-中文(简体)版.zip 对应Maven信息:groupId:org.springframework.plugin,artifactId:spring-plugin-metadata,version:1.2.0....
包含翻译后的API文档:spring-plugin-core-2.0.0.RELEASE-javadoc-API文档-中文(简体)-英语-对照版.zip; Maven坐标:org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE; 标签:spring、core、plugin、...
赠送jar包:jfinal-mail-plugin-3.0.jar; 赠送原API文档:jfinal-mail-plugin-3.0-javadoc.jar; 赠送源代码:jfinal-mail-plugin-3.0-sources.jar; 赠送Maven依赖信息文件:jfinal-mail-plugin-3.0.pom; 包含...