簡體   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