Java軟件報表軟件技術博客

          java報表軟件技術匯總 java報表軟件制作 報表軟件新聞
          posts - 355, comments - 100, trackbacks - 0, articles - 3
             :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理

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

          下圖為一個雇員統計表:

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

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

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

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

          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.

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

          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



          主站蜘蛛池模板: 平顶山市| 黔江区| 北宁市| 临江市| 石家庄市| 石河子市| 盖州市| 青川县| 云南省| 金山区| 阜南县| 沐川县| 邵阳市| 潢川县| 宁海县| 株洲市| 通城县| 政和县| 晋州市| 昂仁县| 舞阳县| 丹江口市| 周口市| 平陆县| 墨玉县| 东乡县| 望都县| 贺州市| 乌拉特中旗| 怀集县| 准格尔旗| 梧州市| 乡宁县| 邵武市| 博白县| 蓬溪县| 水城县| 扶绥县| 昌宁县| 红河县| 兴文县|