阳光网驿-企业信息化交流平台【DTC零售连锁全渠道解决方案】

 找回密码
 注册

QQ登录

只需一步,快速开始

扫描二维码登录本站

手机号码,快捷登录

老司机
查看: 1683|回复: 2

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

[复制链接]
  • TA的每日心情
    郁闷
    2012-8-20 14:41
  • 签到天数: 22 天

    [LV.4]偶尔看看III

    发表于 2011-11-14 12:33:26 | 显示全部楼层 |阅读模式
    本例以一个实例来展现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
    楼主热帖
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    开心
    2013-11-12 17:22
  • 签到天数: 116 天

    [LV.6]常住居民II

    发表于 2011-12-7 23:02:39 | 显示全部楼层
    好文章,值得好好学习学习,谢谢楼主,支持一下
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    无聊
    昨天 08:14
  • 签到天数: 2107 天

    [LV.Master]伴坛终老

    发表于 2016-10-29 18:01:59 | 显示全部楼层
    支持一下
    - 本文出自阳光网驿--企业信息化专家,原文地址:http://bbs.sunwy.org/thread-220819-1-1.html
    启用邀请码注册,提高发帖质量,建设交流社区
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    快速回复 返回顶部 返回列表