gpt4 book ai didi

Java程序将birt报告导出到excel

转载 作者:行者123 更新时间:2023-12-01 11:09:50 26 4
gpt4 key购买 nike

嗨,我想通过 ubuntu 机器中的 java 程序运行我的 birt 报告,并且还需要导出为 xlsx 格式。有什么办法可以做到这一点吗?我可以找到运行 birt 报告,但找不到导出报告的程序。

我正在查找的代码是:here 。但它导出 HTML 我想要 xlsx 格式,而且此示例中的一些类已被废弃。

我怎样才能实现这个目标,请有人帮助我吗?

最佳答案

这实际上很简单。导出到 XSLX 是 birt 运行时“开箱即用”的功能,您不需要任何自定义发射器。

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

就是这样。

只是一个简单的代码(我在这里留下了不必要的东西):

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,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32499962/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com