我使用以下代碼創建了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在生成時處理報告。所以你的想法是正確的,因爲我的理解是正確的。 –