<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)  編輯  收藏 所屬分類: eclipsebirt

    首先,本文講的方法適合的環境是:使用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 小攤
    可以給我一份嗎?呵呵
    主站蜘蛛池模板: 亚洲色欲色欲www在线播放| 美女被吸屁股免费网站| 97se亚洲国产综合自在线| 国产精品亚洲专区无码唯爱网 | 四虎永久成人免费影院域名| 国产亚洲精品拍拍拍拍拍| 亚洲一级免费毛片| WWW国产成人免费观看视频| 最新免费jlzzjlzz在线播放| 亚洲国产精品成人精品无码区 | 亚洲人成无码网站在线观看| 国产精品无码免费专区午夜 | 午夜亚洲AV日韩AV无码大全| 精品韩国亚洲av无码不卡区 | **毛片免费观看久久精品| 亚洲精品tv久久久久久久久久| 亚洲国产日韩在线成人蜜芽| 国产午夜无码片免费| 国产精品色午夜免费视频| 亚洲福利电影在线观看| 中文字幕av免费专区| 亚洲高清视频在线观看| 18禁超污无遮挡无码免费网站国产| 亚洲AV人无码综合在线观看| 国产精品免费福利久久| 91麻豆精品国产自产在线观看亚洲| 亚洲精华液一二三产区| 日韩精品无码区免费专区| 亚洲精品色在线网站| 亚洲五月综合缴情在线观看| 一级毛片免费全部播放| 亚洲国产精品毛片av不卡在线| 国产亚洲欧美日韩亚洲中文色| 亚洲一区二区三区在线观看精品中文| 久久久精品免费国产四虎| 亚洲AV永久精品爱情岛论坛| 岛国精品一区免费视频在线观看 | 在线亚洲精品自拍| 成人免费福利视频| 亚洲一区二区三区国产精品无码| 国产精品久久免费视频|