FineReport报表工具6.5离线填报示例

本例以一个实例来展现FineReport报表工具离线填写报表功能。

下图为一个雇员统计表:

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

FineReport报表设计器里的报表设计如下图:

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.。

运行如下导入程序即可将数据导入数据库中,注意此处要特别留心程序中几个路径是否正确。

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 {

       publicvoid exe() {

              //配置系统运行环境,可以localEnvremoteEnv

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

              try{

                     //设置

                     FRContext.setCurrentEnv(env);

                     //读取模板

                     ReportTemplatetpl = env.readTemplate("WorkBook1.cpt");

                     //读取Excel文件

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

                     //调用方法,具体如下

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

              }catch (Exception e) {

                     //TODO Auto-generated catch block

                     e.printStackTrace();

              }

             

       }

       publicstatic void main(String[] args)

       {

              TestUtilstestUtils = new TestUtils();

              testUtils.exe();

       }

}

查看FineReport报表中数据见下图:

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

至此离线填报成功。

文章转自:http://blog.vsharing.com/fanfanzheng/A1444756.html

转载于:https://my.oschina.net/u/194678/blog/35147

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值