问题
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