我使用以下代码创建了一个BIRT 4.3.0报告。要点是:我想向dataSet传递一个参数foo:
public File actionPdf() throws EngineException {
IReportEngine engine = getEngine();
// Open the report design
IReportRunnable design = null;
design = engine.openReportDesign("c:\\hello_world.rptdesign");
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
task.setParameterValue("foo", "bar");
task.validateParameters();
PDFRenderOption PDF_OPTIONS = new PDFRenderOption();
File f = new File("xyz.pdf");
PDF_OPTIONS.setOutputFileName(f.getAbsolutePath());
PDF_OPTIONS.setOutputFormat("pdf");
task.setRenderOption(PDF_OPTIONS);
task.run();
task.close();
return f;
}dataSet如下所示:
public class ActionsPerDateDataSet implements IPojoDataSet {
public void open(Object obj, Map<String,Object> map) {
System.out.println( obj + " map: " + map + " size: " + map.size())
}
2015-11-03T13:23:18.993+0100|Information {org.eclipse.datatools.connectivity.oda.util_consumerResourceIds=org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers@24a1f3df, org.eclipse.birt.data.engine.expression.compareHints=org.eclipse.birt.data.engine.expression.CompareHints@99fdef1, OdaConsumerId=org.eclipse.datatools.connectivity.oda.profile.connectionPropertyService, PDF_RENDER_CONTEXT=org.eclipse.birt.report.engine.api.PDFRenderContext@491c843} map: {} size: 0但是没有参数foo set.How,我能得到它吗?
发布于 2015-11-03 22:38:45
从外部,将参数传递到报表,而不是传递到数据集。您必须区分报表参数和数据集参数。在报表中,数据集参数可以从报表参数中获取其值,但这不是自动的。dataset参数还可以从布局上下文中获取其值(请参见属性中的dataset参数绑定按钮)。
有关详细信息,请参阅BIRT文档。
如果您来自其他报表设计工具,您可能会发现这很麻烦和过于复杂,但实际上它是一个很好的功能,因为它允许在报表中多次重用相同的数据集,并且是通过从库中引用组件来重用组件的基础。
发布于 2017-03-15 23:02:39
您需要在报表设计中定义参数。


https://stackoverflow.com/questions/33499162
复制相似问题