繁体   English   中英

使用XML数据源生成动态BIRT报告时出现问题

[英]Issue in generating Dynamic BIRT reports using XML data source

我们正在使用BIRT 3.7 API生成动态PDF。 我们正在使用以下逻辑来设置XML数据源。 在下面的代码段中,我们提供XML字符串作为数据源。 奇怪的是,由于上周没有从xml中填充动态数据。 即使在FINEST日志级别,它也不会引发任何异常。 由于我们尚未更新任何jar,因此无法找出导致此功能中断的更改。 PDF生成时没有动态值。

还有什么我可以尝试将java中的xml数据源设置为birt模板的。

String paramStr = readFileAsString(servletContext.getRealPath("/WEB-INF/classes")
+ "/resources/test.xml");

FileInputStream fis = new FileInputStream(servletContext.getRealPath("/WEB-INF/classes")
+ "/resources/BirtXmlDataTest.rptdesign");
IReportRunnable design = birtReportEngine.openReportDesign(fis);
DesignElementHandle designElementHandle = design.getDesignHandle();
ModuleHandle moduleHandle = designElementHandle.getModuleHandle();
ElementFactory designElementFactory = designElementHandle.getElementFactory();
OdaDataSourceHandle dataSourceHandle = designElementFactory.newOdaDataSource("Data Source",
"org.eclipse.birt.report.data.oda.xml");

moduleHandle.getDataSources().add(dataSourceHandle);

IRunAndRenderTask task = birtReportEngine
.createRunAndRenderTask(design);
PDFRenderOption options = new PDFRenderOption();
options.setSupportedImageFormats("JPG;PNG;BMP;SVG");
options.setOutputFormat(PDFRenderOption.OUTPUT_FORMAT_PDF);
options.setEmitterID(PDFRenderOption.OUTPUT_EMITTERID_PDF);
// options.setOutputStream(response.getOutputStream());
File file = new File("d:\\test" + File.separator + "file2.pdf");
FileOutputStream fos = new FileOutputStream(file);
// options.setOutputStream(response.getOutputStream());
options.setOutputStream(fos);

HashMap<String, Object> contextMap = new HashMap<String, Object>();
contextMap.put("org.eclipse.birt.report.data.oda.xml.inputStream",
new ByteArrayInputStream(paramStr.getBytes()));
contextMap.put(
"org.eclipse.birt.report.data.oda.xml.closeInputStream",
Boolean.TRUE);
task.setAppContext(contextMap);
task.setRenderOption(options);
task.run();
task.close();

您在哪里为任务设置报告参数? 如果您将这些值称为动态值 ,那么您需要的是:

task.setParameterValue("param_name", value);

只要遵循这种模式 否则,您显然会得到一个空白报告,因为未指定任何参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM