Java program to export birt report to excel

前端 未结 1 1281
醉话见心
醉话见心 2021-01-28 00:45

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

相关标签:
1条回答
  • 2021-01-28 01:05

    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();
    
    0 讨论(0)
提交回复
热议问题