dongyue7796 2012-02-20 09:59
浏览 38
已采纳

Zend Server CE和BIRT与Javabridge集成[关闭]

I was able to get the Zend Server Java Bridge running and tested it successfully, but I am unable to find any information on how to get the Birt Engine to work with the Zend Server Java Bridge. Has anyone figured out how to get this to work?

i am facing the same issue can locate where to download the birt api to run birt reports

viewtopic.php?f=44&t=9452&p=30950&hilit=birt#p30950

If anybody have an example... please... show me how to do it... Thank you.

  • 写回答

3条回答 默认 最新

  • douchungu0859 2012-02-27 11:46
    关注

    If you download the 3.7 runtime you should be able to build a command line app that runs the reports. Attached is a simple example. To build the class make sure you have the jars from the runtime download/reportengine/lib directory in the classpath. Once built you should be able to call it the same way as the simple Java app. This sample does a platform startup and shutdown which is generally not a good idea if you are going to generate a lot of reports. A better solution is to wrap the Platform startup and report engine creation in a singleton that starts when you server starts up, then use the engine to create a new task per request.

    import java.util.logging.Level;
    
    import org.eclipse.birt.core.framework.Platform;
    import org.eclipse.birt.report.engine.api.EXCELRenderOption;
    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.HTMLRenderOption;
    import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
    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;
    import org.eclipse.birt.report.engine.api.PDFRenderOption;
    import org.eclipse.birt.report.engine.api.RenderOption;
    import org.eclipse.birt.report.engine.api.impl.RunAndRenderTask;
    import org.eclipse.birt.report.engine.api.script.IReportContext;
    
    
    public class RunAndRenderTaskTest {
    
    public void runReport() throws EngineException
    {
    
    RunAndRenderTask task=null;
    IReportEngine engine=null;
    EngineConfig config = null;
    
    try{
    config = new EngineConfig( );   
    //config.setLogConfig("c:/dwn", Level.SEVERE);
    //config.setResourcePath("C:/work/workspaces/3.7.1workspaces/BIRT 
    Metal/APIs/resources");
    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("Reports/testlibrary.rptdesign");
    task = (RunAndRenderTask) engine.createRunAndRenderTask(design);    
    IReportContext irc = task.getReportContext();
    //task.setParameterValue("Top Count", (new Integer(5)));
    //task.validateParameters();
    
    
    //HTMLRenderOption options = new HTMLRenderOption();    
    //options.setImageDirectory("./");
    //options.setOutputFileName("output/resample/external.html");
    //options.setOutputFormat("html");
    //options.setEmbeddable(false);
    //options.setEnableMetadata(true);
    //options.setEnableInlineStyle(false);
    //options.setEnableAgentStyleEngine(true);
    //options.setEnableCompactMode(true);
    
    //PDFRenderOption options = new PDFRenderOption();
    //options.setOutputFileName("output/resample/hidefooter.pdf");
    //options.setSupportedImageFormats("PNG;GIF;JPG;BMP;SWF;SVG");
    //options.setOutputFormat("pdf");
    
    //EXCELRenderOption options = new EXCELRenderOption();  
    //options.setOutputFormat("xls");
    //options.setOutputFileName("output/resample/customers.xls");
    //options.setWrappingText(true);
    
    HTMLRenderOption options = new HTMLRenderOption();
    //options.setImageHandler(new HTMLServerImageHandler());
    options.setSupportedImageFormats("JPG;PNG;BMP;SVG;GIF");
    options.setOutputFileName("output/resample/testlibrary.html");
    options.setOutputFormat("html");
    //options.setOutputFormat("ppt");
    
    
    
    task.setRenderOption(options);
    task.run();
    
    irc = task.getReportContext();
    
    task.close();
    engine.destroy();
    }catch( Exception ex){
    ex.printStackTrace();
    }   
    Platform.shutdown( );
    System.out.println("Finished");
    
    
    
    }   
    
    
    /**
    * @param args
    */
    public static void main(String[] args) {
    try
    {
    
    RunAndRenderTaskTest ex = new RunAndRenderTaskTest( );
    ex.runReport();
    
    System.exit(0);
    
    }
    catch ( Exception e )
    {
    e.printStackTrace();
    }
    }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!