隨筆 - 225  文章 - 98  trackbacks - 0
          <2011年11月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          隨筆分類

          相冊

          報表工具廠商們

          搜索

          •  

          最新評論

          閱讀排行榜

          本例以一個實例來展現java報表工具FineReport離線填寫報表功能。

          下圖為一個雇員統計表:

          http://www.finereport.com/forumimages/lxtbsm1.jpg

          FineReport報表設計器里的報表設計如下圖:

          http://www.finereport.com/forumimages/lxtbsm2.jpg

          模板中FineReport報表填報屬性如下:

          http://www.finereport.com/forumimages/lxtbsm3.jpg

          保存該模板到C:\FineReport6.2\WebReport\WEB-INF\reportlets目錄下,命名為WorkBook1.cpt

          依次點擊FineReport文件à輸出àExcel格式à原樣導出,得下圖的.xls文件:

          http://www.finereport.com/forumimages/lxtbsm4.jpg

          填寫雇員信息如下:

          http://www.finereport.com/forumimages/lxtbsm5.jpg

          將其另存,路徑為C:\WorkSheet1.xls.。

          運行如下導入程序即可將數據導入數據庫中,注意此處要特別留心程序中幾個路徑是否正確。

          import java.io.FileInputStream;

          import java.util.HashMap;

           

          import com.fr.base.FRContext;  

          import com.fr.base.dav.LocalEnv;

          import com.fr.report.ReportTemplate;

          import com.fr.report.io.ExcelImporter;

           

          public class TestUtils {

                 public void exe() {

                        // 配置系統運行環境,可以localEnv remoteEnv

                        com.fr.base.dav.LocalEnv env = new LocalEnv("C:\\FineReport6.5\\WebReport\\WEB-INF");

                        try {

                               // 設置

                               FRContext.setCurrentEnv(env);

                               // 讀取模板

                               ReportTemplate tpl = env.readTemplate("WorkBook1.cpt");

                               // 讀取Excel文件

                               FileInputStream file = new FileInputStream("C:\\WorkSheet1.xls");

                               // 調用方法,具體如下

                               ExcelImporter.importExcel(tpl, new HashMap(), file);

                        } catch (Exception e) {

                               // TODO Auto-generated catch block

                               e.printStackTrace();

                        }

                       

                 }

                 public static void main(String[] args)

                 {

                        TestUtils testUtils = new TestUtils();

                        testUtils.exe();

                 }

          }

          查看報表中數據見下圖:

          http://www.finereport.com/forumimages/lxtbsm6.jpg

          至此離線填報成功。
          文章轉自:http://blog.vsharing.com/fanfanzheng/A1444756.html



          了解Java報表工具就從這里開始
          posted on 2011-11-14 11:07 season 閱讀(207) 評論(0)  編輯  收藏 所屬分類: Java報表—技術知識
          主站蜘蛛池模板: 汉源县| 长葛市| 侯马市| 荣成市| 利辛县| 会宁县| 鄂托克旗| 闻喜县| 石狮市| 平果县| 英德市| 宝兴县| 华宁县| 米易县| 宜州市| 信阳市| 宁远县| 苍山县| 徐水县| 萨嘎县| 武威市| 南城县| 沽源县| 常宁市| 喀喇| 从江县| 通州市| 铜川市| 巢湖市| 镇康县| 湾仔区| 弋阳县| 渝中区| 福州市| 中宁县| 精河县| 沁水县| 宁国市| 从化市| 织金县| 安乡县|