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