2
我正在尋找編碼BIRT API w/a數據源的方向。我不確定如何配置我的應用程序以訪問創建的數據源。如果我能得到一些幫助,這將是很好的。這是我的位置。我已經通過BIRT RCP創建了一個報告。現在我正在尋找使用常規Java應用程序和Web應用程序生成報告。兩者都將通過我將要創建的GUI傳遞日期參數。兩者都需要有一個數據源。我已經看到了一些使用報表設計器的例子,但我沒有使用它。我也沒有使用BIRT報告創建器(RCP)GUI來生成這個。通過API設置BIRT數據源
感謝
import java.util.logging.Level;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
public class ReportGenerator {
public static void main(String args[]) throws EngineException {
ReportGenerator reportGenerator = new ReportGenerator();
reportGenerator.executeReport();
}
public void executeReport() throws EngineException {
IReportEngine engine=null;
EngineConfig config = null;
try{
config = new EngineConfig();
config.setBIRTHome("C:\\birt-rcp-report-designer-3_7_2\\ReportEngine");
config.setLogConfig("c:/temp/test", Level.FINEST);
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(config);
IReportRunnable design = null;
//Open the report design
design = engine.openReportDesign("ReportTemplates/testNoData.rptdesign");
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
task.setParameterValue("AuthorName", "Dale DeMott");
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFileName("output/resample/Parmdisp.html");
options.setOutputFormat("html");
task.setRenderOption(options);
//Looking to create and insert a datasource here.
//task.setDataSource(some parameters here that represent the ds);
task.run();
task.close();
engine.destroy();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
Platform.shutdown();
}
}
}