2013-01-03 73 views
1

我想在Eclipse Indigo中將先前設計的BIRT報表呈現爲HTML。我正在使用BIRT 4.2.1。當我在普通的Java應用程序中執行它時,它運行良好。但是,當我想從RCP應用程序執行相同的操作時,它不會。在Birt報表引擎API中不支持OutputFormat

這是我的代碼:

IRunAndRenderTask task=null; 
    IReportEngine engine=null; 
    EngineConfig config = null; 
    IReportRunnable design = null; 

    try{ 

     config = new EngineConfig(); 

     IReportEngineFactory factory = (IReportEngineFactory) Platform. 
     createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY); 

     engine = factory.createReportEngine(config); 
     //use this if the report is in the bundle 
     Bundle bundle = org.eclipse.core.runtime.Platform.getBundle("com.accenture.workforceplanning.ui");  
     URL url = FileLocator.find(bundle, new Path("/reports/scenarioAnalysis.rptdesign"), null); 
     String rpt = FileLocator.toFileURL(url).getPath(); 

    //Open the report design 
    design = engine.openReportDesign(rpt); 
    task = engine.createRunAndRenderTask(design); 


    HTMLRenderOption options = new HTMLRenderOption();  
    options.setImageDirectory("./"); 
    URL url1 = FileLocator.find(bundle, new Path("/reports"), null); 
    String rpt1 = FileLocator.toFileURL(url1).getPath(); 
    options.setOutputFileName(rpt1 +"/scenarioAnalysis.html"); 
    options.setOutputFormat("html"); 

    task.setRenderOption(options); 
    task.run(); 
    task.close(); 
    engine.destroy(); 
    }catch(Exception ex){ 
     ex.printStackTrace(); 
    }    

當程序到達task.run()我收到以下錯誤:

org.eclipse.birt.report.engine.api.UnsupportedFormatException: The output format html is not supported. 
    at org.eclipse.birt.report.engine.api.impl.EngineTask.setupRenderOption(EngineTask.java:2047) 
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:96) 
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77) 
    at com.accenture.workforceplanning.ui.composites.OutputComposite.reportToHtml(OutputComposite.java:470) 
    at com.accenture.workforceplanning.ui.composites.OutputComposite.createReportScenarioAnalysis(OutputComposite.java:410) 
    at com.accenture.workforceplanning.ui.composites.OutputComposite.access$6(OutputComposite.java:308) 
    at com.accenture.workforceplanning.ui.composites.OutputComposite$4.widgetSelected(OutputComposite.java:214) 
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240) 
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) 
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165) 
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754) 
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) 
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) 
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) 
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) 
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) 
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) 
    at com.accenture.workforceplanning.application.Application.start(Application.java:26) 
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) 
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) 
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410) 
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386) 

它發生於任何類型的OUTPUTFORMAT一樣,我想渲染。

任何想法我做錯了什麼?

感謝

Yulexi

回答

1

我設法解決問題。以防萬一有人遇到同樣的問題,這是我做的: 我手動添加了所有BIRT插件到我的RCP應用程序產品的依賴項(出於某種原因,所需插件未添加) 。我仍然不知道缺少的插件是什麼。但現在應用程序正常工作。