<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 20, comments - 16, trackbacks - 0, articles - 0

    birt中動態數據的實現

    Posted on 2008-01-23 13:54 Raul Gong 閱讀(2779) 評論(13)  編輯  收藏 所屬分類: eclipse 、birt

    首先,本文講的方法適合的環境是:使用xml作為birt的數據源,但不同場合需要不同的xml文件,但制作.rptdesign文件時只運行輸入一個xml文件,怎樣實現動態數據源呢?以下將解決這個問題。

    同時,本文所講的方法,可以稍加改造,適合所有需要管理器向.rptdesign文件傳入參數的情況。例如,你不僅需要動態數據源,還可以需要動態的報表標題、某處的文字、動態的參數、等等。

    在這里,我只說思路代碼,具體細節,見我提供的實例工程。

    這里,我以插件工程為例。首先,建立一個工程,然后是建一個.rptdesign,在其中的數據源,選xml,然后使用如下的xml文件的路徑:

    <ROOT>
        
    <FACTOR NAME="Maintainability">
          
    <PECENT NAME="Execllent" VALUE="0.00"/>
          
    <PECENT NAME="Good" VALUE="0.75"/>
          
    <PECENT NAME="Fair" VALUE="0.25"/>
          
    <PECENT NAME="Poor" VALUE="0.00"/>
        
    </FACTOR>
    </ROOT>

     

    注意在outline視圖中選中 Data Source ,然后在屬性窗口中選中 Event Handler ,在里面填入類的地址:

    net.rual.learn.eventhandler.FunTableHandler

    然后在相應位置建立這個FunTableHandler類,繼承至DataSourceEventAdapter類,覆蓋beforeOpen方法,如下:

     

    package net.raul.lern.eventhandler;

    import org.eclipse.birt.report.engine.api.script.IReportContext;
    import org.eclipse.birt.report.engine.api.script.eventadapter.DataSourceEventAdapter;
    import org.eclipse.birt.report.engine.api.script.instance.IDataSourceInstance;

    /**
     * 
    @author Vincent
     * 
     
    */

    public class FunTableHandler extends DataSourceEventAdapter {


        @Override
        
    public void beforeOpen(IDataSourceInstance dataSource,
                IReportContext reportContext) 
    {
            
    // TODO Auto-generated method stub

            String xmlFile 
    = (String) reportContext.getReportRunnable()
                    .getReportEngine().getConfig().getProperty(
    "user.datasource");
            
    // xmlFile =
            
    // "E:/c.xml";
            dataSource.setExtensionProperty("FILELIST", xmlFile);
            
    super.beforeOpen(dataSource, reportContext);
        }


    }


    然后編寫管理器類:

        public String executeReport(String repPath, String xmlFilePath,
                String FileName, String FunName) 
    throws EngineException {
            String outPutFilePath 
    = proPath + "/report/" + FunName + "_"
                    
    + FileName.substring(0, FileName.length() - 4+ ".html";

            
    // Engine Configuration - set and get temp dir, BIRT home, Servlet
            
    // context
            EngineConfig config = new EngineConfig();
            
    // config.setEngineHome(
            
    // "E:/work/eclipses/eclipse4birt/birt-runtime-2_2_1_1/ReportEngine" );
            config.setEngineHome(getEnvirStr("BIRT_HOME"+ "/ReportEngine");
            
            config.setProperty(
    "user.projectclasspath",
                    
    "E:/work/workspaces/kaudit/kaudit.071224/com.zte.audit.ui/bin");
            config.setProperty(
    "user.datasource", xmlFilePath);
            
    // config.setProperty("user.funname", "main");
            
    // 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(repPath);
            
    // Create task to run the report - use the task to execute and run the
            
    // report,
            IRunAndRenderTask task = engine.createRunAndRenderTask(design);
            task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY,
                    FunTableHandler.
    class.getClassLoader());
            
    // IReportRunnable runnable = engine.openReportDesign( source );
            
    // 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);
            
    // contextMap
            
    // .put(EngineConstants.PROJECT_CLASSPATH_KEY,
            
    // "E:/work/workspaces/kaudit/kaudit.071224/com.zte.audit.ui/bin");
            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("D:/customer.html");
            options.setOutputFileName(outPutFilePath);
            options.setOutputFormat(
    "html");
            task.setRenderOption(options);
            
    // run the report and destroy the engine
            task.run();
            
    // task.addScriptableJavaObject(arg0, arg1)
            engine.destroy();

            
    return outPutFilePath;
        }


        
    public static String getEnvirStr(String name) {
            
    // System.getenv("BIRT_HOME");
            return System.getenv(name);
        }



    因為時間很緊,我沒有辦法寫得很詳細,等過年放假的時候,我好好整理,再放上來。

    Feedback

    # re: birt中動態數據的實現[未登錄]  回復  更多評論   

    2008-03-26 11:04 by cxh
    寫的好,繼續呀

    # re: birt中動態數據的實現[未登錄]  回復  更多評論   

    2008-05-12 18:16 by cxh
    老大,例子程序傳一份,讓俺也學習學習

    # re: birt中動態數據的實現  回復  更多評論   

    2008-05-19 12:32 by Raul Gong
    @cxh
    好的,你的郵箱是多少?你也可以加我的msn哈:
    vincent.gong@hotmail.com

    # re: birt中動態數據的實現  回復  更多評論   

    2008-07-04 13:48 by RogerTu
    BIRT開發團隊就在國內,關于BIRT的問題,推薦BIRT官方中文論壇http://www.actuatechina.com/index.php,工程師們的響應還是贊的

    # re: birt中動態數據的實現  回復  更多評論   

    2008-09-27 10:26 by new birt
    老大給我一份,行不嘛
    jinsui_sc@163.com
    謝謝!

    # re: birt中動態數據的實現  回復  更多評論   

    2008-10-21 14:09 by jm
    多謝!讀了后幫助很大。

    # re: birt中動態數據的實現  回復  更多評論   

    2009-02-04 14:04 by fzl
    能否給發一份完整的實例,謝謝!
    郵箱:fanzengl@eastsoft.com.cn

    # re: birt中動態數據的實現[未登錄]  回復  更多評論   

    2009-04-10 00:49 by test
    http://www.javaworld.com/javaworld/jw-06-2008/jw-06-osgi3.html?page=5

    # re: birt中動態數據的實現[未登錄]  回復  更多評論   

    2009-04-10 01:02 by test
    http://developer.51cto.com/java/

    # re: birt中動態數據的實現[未登錄]  回復  更多評論   

    2009-05-09 00:45 by test
    flex
    http://www.jeromeloo.cn/?page_id=180
    http://livedocs.adobe.com/flex/3/html/help.html
    http://www.jeromeloo.cn/wp-demo/SpringGraph/SpringGraphDemo.htm
    http://www.diybl.com/course/1_web/webjs/200877/131260.html
    l

    # re: birt中動態數據的實現[未登錄]  回復  更多評論   

    2009-05-09 00:52 by test
    http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1048510#

    # re: birt中動態數據的實現[未登錄]  回復  更多評論   

    2009-09-09 10:54 by test
    http://www.cnblogs.com/wyqtomorrow/archive/2007/05/19/752275.html

    # re: birt中動態數據的實現  回復  更多評論   

    2012-07-26 09:22 by 小攤
    可以給我一份嗎?呵呵
    主站蜘蛛池模板: 噜噜噜亚洲色成人网站∨| 亚洲A∨无码一区二区三区| 亚洲综合无码一区二区三区| 国产在线观看无码免费视频| 特级无码毛片免费视频尤物| 久久国产亚洲观看| 无人在线观看免费高清| 亚洲日本中文字幕| 亚洲美女免费视频| 亚洲三级在线观看| 免费高清资源黄网站在线观看| 欧美日韩亚洲精品| 亚洲免费闲人蜜桃| 337p日本欧洲亚洲大胆裸体艺术| 亚洲最大福利视频| 四虎国产成人永久精品免费| 99亚洲精品高清一二区| 成人免费777777被爆出| 亚洲国产精彩中文乱码AV| 免费一区二区三区| 亚洲中文字幕无码日韩| 久久精品成人免费看| 久久亚洲熟女cc98cm| 午夜色a大片在线观看免费| 国产亚洲精品美女久久久久 | 亚洲人成国产精品无码| 久久乐国产综合亚洲精品| 精品国产免费观看一区| 国产精品成人免费观看| 免费萌白酱国产一区二区| 亚洲砖码砖专无区2023| 美女裸身网站免费看免费网站| 亚洲欧洲无码AV不卡在线| 四虎永久在线精品视频免费观看| 久久久久久久久久久免费精品| 亚洲精品无码永久在线观看| 久爱免费观看在线网站| 亚洲av永久无码精品国产精品| 无码区日韩特区永久免费系列| 亚洲AV一宅男色影视| 女人18毛片a级毛片免费|