Java程序将Birt报告导出到Excel [英] Java program to export birt report to excel

查看:360
本文介绍了Java程序将Birt报告导出到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过ubuntu机器上的Java程序运行我的Birt报告,还需要导出为xlsx格式.有什么办法吗?我可以找到运行Birt报告,但找不到用于导出报告的程序.

Hi i wanna run my birt report through a java program in ubuntu machine and also need to export to xlsx format. Is any way to do this? I can find to run birt report but not able to find program to export the report.

我正在查找的代码是:此处.但是它导出了HTML,但我希望使用xlsx格式,此外,本示例中的某些分类也已描述.

The code i am looking is : here. But it export HTML i want xlsx format, moreover some of the classed in this example are depricated.

我该如何做到这一点,请任何人帮助我?

How can i achieve this please anyone help me?

推荐答案

这实际上很容易.导出到XSLX是birt运行时开箱即用"的操作,您不需要任何自定义的发射器.

This is actually quite easy. Export to XSLX is something that birt runtime is doing "out of the box" and you do not need any custom emmiters.

因此,如果您已经将代码导出到PDF或其他任何东西,则只需创建不同的渲染选项(对于PDF,它可能只是一个RenderOption,对于XSLX,您需要EXCELRenderOption),然后在选项上调用:option.setOutputFormat("xlsx").

So, if you already have code exporting to PDF or anything, you just create different render options (for PDF it might be just a RenderOption, for XSLX you need EXCELRenderOption), and on the options call: option.setOutputFormat("xlsx").

就是这样.

只需一个简单的代码(我将不必要的东西放在这里):

Just a simple code (I leave unneccessery stuff out of here):

ReportEngine re = new ReportEngine(engineConfig); //you need engine config, might be default
IReportRunnable runnable = re.openReportDesign(is);
IRunAndRenderTask task = re.createRunAndRenderTask(runnable);
IRenderOption option = new EXCELRenderOption();
option.setOutputFormat("xlsx");
option.setOutputStream(hereWillBeYourReport);
task.setRenderOption(option);
task.run();
task.close();

这篇关于Java程序将Birt报告导出到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆