java - 在 xlsx 中自动下载 birt 报告
问题描述
我开发了一个 BIRT 报告,它工作正常,但是当我打开一个 HTML 预览屏幕并在那里我可以将它导出为不同的格式时,我希望人们运行或报告时自动下载 Excel 格式(xlsx),我见过几个类型,我得到了 java 代码,但它有一些错误(在打开报告的部分),我也不确定如何在我的报告(.rptdesign)中引用该 java 代码。你能帮我执行这个自动导出过程吗?谢谢!
公共类 EXCELRenderOption 扩展 RenderOption{
// Open report design
IReportRunnable design = BidiLine.openReportDesign(sc.getRealPath("/report/") + reportName + ".rptdesign");
ReportDesign report = (ReportDesignHandle) design.getDesignHandle();
// create task to run and render report
task = birtEngine.createRunAndRenderTask(design);
res.setContentType("application/vnd.ms-excel");
res.setHeader("Content-Disposition", "attachment; filename=\"" + "xcel.xls" + "\"");
EXCELRenderOption options = new EXCELRenderOption();
options.setOutputFormat("xlsx");
res.setHeader("Content-Disposition", "inline; filename=report.xlsx");
options.setOutputFileName("corporate-batches-summary-report.xlsx");
options.setOutputStream(res.getOutputStream());
task.setRenderOption(options);
task.run();
task.close();
解决方案
推荐阅读
- javascript - 使用 Javascript 创建待办事项列表。这是一个附加问题
- python - Heroku 不会运行最新的 python 文件
- lua - 在 LOVE 中创建光标
- javascript - 带有逻辑的 Vue JS 选择
- python - 如何在 Python dict 值之间插入新行
- linux - 范围内的 For 循环迭代在 bash 中不起作用
- entity-framework-core - 包含在所有拆分查询中找到的引用导航属性的左外连接语句
- linux - prctl、set_pdeathsig 在 perl 中是如何工作的?
- javascript - 仅在加载后返回图像
- android - 我无法使用 maven-publish 插件发布 android 库