基于 angularjs+jfinal 的 excel文件导出

使用的jar包 为: poi 我的下载分享里有。

Js: 
$scope.expExcel = function() {
    var start=$("#start").val();
    var end    =$("#end").val();
    var state =$scope.searchInfo.state;
    var name =$scope.searchInfo.name;
        
        window.open("withdraw/expExcel?state=" +state
                + "&start=" + start+ "&end=" + end+ "&name=" + name  );
        
    };

controller :
    @Clear
    public void expExcel() throws ParseException, IOException {
        SimpleDateFormat sb = new SimpleDateFormat("yyyy-MM-dd");
        String start = getPara("start");
        String end = getPara("end");
        Date startDate = null;
        Date endDate = null;
        if (StringUtils.isNotEmpty(start)) {
            startDate = sb.parse(start);
        }
        if (StringUtils.isNotEmpty(end)) {
            endDate = sb.parse(end);
        }
        // 获取导出集合
        List<WithdrawHistory> billList = WithdrawHistory.dao.getBillList(getPara("state"), getPara("name"), startDate, endDate);
        // 开始Excel导出
        String EXPORT_PATH = getSession().getServletContext().getRealPath("");
        System.out.println(" EXPORT_PATH:" + EXPORT_PATH);
        File file = new File(EXPORT_PATH + File.separator + "提现履历信息.xls");
        if (file.exists()) {
            file.delete();
        }

        // 工作簿
        HSSFWorkbook wb = new HSSFWorkbook();
        // 表单
        HSSFSheet sheet = wb.createSheet("提现履历");

        // 表头
        HSSFRow row = sheet.createRow(0);
        HSSFCell cell = row.createCell(0);
        cell.setCellValue("查询条件: ");
        cell = row.createCell(1);
        cell.setCellValue("统计期间(" + start + " ~ " + end + ")");
        cell = row.createCell(2);
        String userName = "无";
        if (StringUtils.isNotEmpty(getPara("name"))) {
            userName = getPara("name");
        }
        cell.setCellValue("用户名:" + userName);
        row = sheet.createRow(1);
        cell = row.createCell(0);
        cell.setCellValue("No.");
        cell = row.createCell(1);
        cell.setCellValue("姓名");
        cell = row.createCell(2);
        cell.setCellValue("开户行");
        cell = row.createCell(3);
        cell.setCellValue("银行账号");
        cell = row.createCell(4);
        cell.setCellValue("转账凭证");
        cell = row.createCell(5);
        cell.setCellValue("提现金额(元)");
        cell = row.createCell(6);
        cell.setCellValue("交易状态");
        cell = row.createCell(7);
        cell.setCellValue("转账时间");
        cell = row.createCell(8);
        cell.setCellValue("操作人员");
        int i = 1;
        for (WithdrawHistory billBo : billList) {

            row = sheet.createRow(i + 1);

            cell = row.createCell(0);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(Integer.toString(i));

            cell = row.createCell(1);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(billBo.getStr("name"));

            cell = row.createCell(2);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(billBo.getStr("bank"));

            cell = row.createCell(3);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(billBo.getStr("account"));

            cell = row.createCell(4);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(billBo.getStr("voucher"));

            cell = row.createCell(5);
            cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
            cell.setCellValue(billBo.getBigDecimal("rmb_num").doubleValue());

            cell = row.createCell(6);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(billBo.getStr("state_str"));

            cell = row.createCell(7);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date transferTime = billBo.getDate("transfer_time");
            String t2 = "";
            if (transferTime != null) {
                t2 = sft.format(transferTime);
            }

            cell.setCellValue(t2);
            cell = row.createCell(8);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(billBo.getStr("operator"));
            i++;
        }
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(file);
            wb.write(fos);
            fos.flush();
        } finally {
            if (fos != null) {
                fos.close();
            }
        }
        render(new FileRender(file, file.getName()));
    }


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
助学金管理系统是一个非常实用的软件,它可以帮助学校或组织更好地管理助学金的发放和使用。基于android+jfinal的助学金管理系统可以让管理员通过手机APP来进行管理,实现了更加便捷的管理方式。 具体实现步骤如下: 1. 确定系统需求 在开发前,需要明确系统所需功能和模块,例如:学生信息管理、助学金申请、审核和发放、统计报表等。同时,还需要确定系统的用户角色和权限,例如:管理员、教师、学生等。 2. 搭建开发环境 开发环境需要搭建Android和JFinal的开发环境,具体可参考相关的开发文档。 3. 设计数据库结构 根据系统需求,设计数据库结构,包括表的名称、字段、数据类型和约束等。常见表包括:学生表、助学金表、申请表、审核表等。 4. 编写后端逻辑 使用JFinal框架编写后端逻辑,包括路由、控制器、模型和视图等。其中,路由负责匹配请求,控制器负责业务处理,模型负责数据访问,视图负责页面展示。 5. 编写前端界面 使用Android Studio编写前端界面,包括登录界面、学生信息管理界面、助学金申请界面、审核界面等。同时,还需要与后端进行接口对接,实现数据的传输和显示。 6. 测试和优化 完成开发后,进行系统测试和优化,确保系统的稳定性和可靠性。 基于android+jfinal的助学金管理系统开发,可以让管理员更加方便地管理助学金,同时也提高了学生申请助学金的效率和准确性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值