我使用以下代码创建了BIRT 4.3.0报告。主要的一点是:我想要一个参数foo
传递到数据集:Birt参数
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;
}
和数据集如下所示:
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=[email protected]24a1f3df, org.eclipse.birt.data.engine.expression.co[email protected]99fdef1, OdaConsumerId=org.eclipse.datatools.connectivity.oda.profile.connectionPropertyService, PDF_REN[email protected]491c843} map: {} size: 0
但没有参数我foo
set.How可以得到它?
是否定义在报告中指出的参数?我现在不活跃地使用birt,所以我回答了我的想法。我记得,一个数据集没有参数。报告可以有参数,您可以在数据集中使用这些参数。 –
hm ...我的计划是使用open方法中的参数从数据库加载数据。这通常是正确的方法吗? – matthias
我记得我做了很多参数。更改数据源,创建查询等。查看报告的生命周期,有几个地方可以让ECMA Script在生成时处理报告。所以你的想法是正确的,因为我的理解是正确的。 –