我正在寻找使用数据源对 BIRT API 进行编码的方向。我不确定如何配置我的应用程序以访问创建的数据源。如果我能得到一些帮助,那就太好了。这就是我所在的地方。我已经通过 BIRT RCP 创建了一个报告。现在我正在寻找使用常规 java 应用程序和 Web 应用程序生成报告。两者都将通过我将创建的 GUI 传递日期参数。两者都需要有数据源。我在这里看到了一些使用报表设计器的示例,但我没有使用它。我也没有使用 BIRT Report Creator (RCP) GUI 来生成它。
谢谢
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();
}
}
}