当前位置: 代码迷 >> Eclipse >> 急救!在java中使用eclipse 的birt 插件的API运行报表总是报错?解决方法
  详细解决方案

急救!在java中使用eclipse 的birt 插件的API运行报表总是报错?解决方法

热度:20   发布时间:2016-04-23 18:45:07.0
急救!在java中使用eclipse 的birt 插件的API运行报表总是报错?
原代码如下:
import   java.util.HashMap;

import   org.eclipse.birt.report.engine.api.EngineConfig;
import   org.eclipse.birt.report.engine.api.EngineConstants;
import   org.eclipse.birt.report.engine.api.EngineException;
import   org.eclipse.birt.report.engine.api.HTMLRenderContext;
import   org.eclipse.birt.report.engine.api.HTMLRenderOption;
import   org.eclipse.birt.report.engine.api.IReportRunnable;
import   org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import   org.eclipse.birt.report.engine.api.ReportEngine;
import   org.eclipse.birt.report.model.api.*;
import   org.eclipse.birt.core.framework.*;
import   org.junit.*;

public   class   TestB   {

  static   void   executeReport()   throws   EngineException
  {
    //Engine   Configuration   -   set   and   get   temp   dir,   BIRT   home,   Servlet   context
    EngineConfig   config   =   new   EngineConfig();
    config.setEngineHome(   "E:/birt/birt-runtime-2.1.2(1)/birt-runtime-2_1_2/ReportEngine "   );  
               
    //Create   the   report   engine
    ReportEngine   engine   =   new   ReportEngine(   config   );
   
   
    //Open   a   report   design   -   use   design   to   modify   design,   retrieve   embedded   images   etc.  
    IReportRunnable   design   =   engine.openReportDesign( "E:/workspace/My   Report/Customers.rptdesign ");  
   
    //Create   task   to   run   the   report   -   use   the   task   to   execute   and   run   the   report,
    IRunAndRenderTask   task   =   engine.createRunAndRenderTask(design);  
   
    //Set   Render   context   to   handle   url   and   image   locataions
    HTMLRenderContext   renderContext   =   new   HTMLRenderContext();
    renderContext.setImageDirectory( "image ");
    HashMap   contextMap   =   new   HashMap();
    contextMap.put(   EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,   renderContext   );
    task.setAppContext(   contextMap   );
   
    //Set   rendering   options   -   such   as   file   or   stream   output,  
    //output   format,   whether   it   is   embeddable,   etc
    HTMLRenderOption   options   =   new   HTMLRenderOption();
    options.setOutputFileName( "c:/customers.html ");
    options.setOutputFormat( "html ");
    task.setRenderOption(options);
   
    //run   the   report   and   destroy   the   engine
    task.run();
   
    engine.destroy();
  }  
  /**
    *   @param   args
    */
  public   static   void   main(String[]   args)   {
  相关解决方案