Java program to export birt report to excel

淺唱寂寞╮ 提交于 2020-01-11 13:06:30

问题


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.

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?


回答1:


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.

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").

And that's it.

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();


来源:https://stackoverflow.com/questions/32499962/java-program-to-export-birt-report-to-excel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!