@RequestMapping(value = "/drawPayFailExport",method = RequestMethod.GET,produces = "application/json")
public ResponseData getAllDrawPayFailExport(HttpServletRequest request, HttpServletResponse response){
String startTime = null;
String endTime = null;
String userName = null;
String accountNumber = null;
if (!"undefined".equals(request.getParameter("startTime"))){
startTime = request.getParameter("startTime");
}
if (!"undefined".equals(request.getParameter("endTime"))){
endTime = request.getParameter("endTime");
}
if (StringUtils.isNotBlank(request.getParameter("userName"))){
userName = request.getParameter("userName");
}
if (StringUtils.isNotBlank(request.getParameter("accountNumber"))){
accountNumber = request.getParameter("accountNumber");
}
DrawPayFailDto drawPayFailDto = new DrawPayFailDto();
drawPayFailDto.setStartTime(startTime);
drawPayFailDto.setEndTime(endTime);
drawPayFailDto.setUserName(userName);
drawPayFailDto.setAccountNumber(accountNumber);
logger.info("兑换提现付款失败导出请求参数:"+JSON.toJSON(drawPayFailDto));
//第一步创建workbook
HSSFWorkbook wb = new HSSFWorkbook();

//第二步创建sheet
HSSFSheet sheet = wb.createSheet("兑换提现付款失败表");

//第三步创建行row:添加表头0行
HSSFRow row = sheet.createRow(0);
HSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER); //居中

//第四步创建单元格
HSSFCell cell = row.createCell(0); //第一个单元格
cell.setCellValue("序号"); //设定值
cell.setCellStyle(style); //内容居中

cell = row.createCell(1); //第二个单元格
cell.setCellValue("申请编号");
cell.setCellStyle(style);

cell = row.createCell(2); //第三个单元格
cell.setCellValue("申请时间");
cell.setCellStyle(style);

cell = row.createCell(3); //第四个单元格
cell.setCellValue("用户姓名");
cell.setCellStyle(style);

cell = row.createCell(4); //第五个单元格
cell.setCellValue("手机号");
cell.setCellStyle(style);

cell = row.createCell(5); //第六个单元格
cell.setCellValue("实际应付金额");
cell.setCellStyle(style);

cell = row.createCell(6); //第七个单元格
cell.setCellValue("退款银行");
cell.setCellStyle(style);

cell = row.createCell(7); //第八个单元格
cell.setCellValue("银行卡号");

cell.setCellStyle(style);

cell = row.createCell(8);//第九个单元格

cell.setCellValue("初审人");

cell.setCellStyle(style);

cell = row.createCell(9); //第十个单元格

cell.setCellValue("复审人");

cell.setCellStyle(style);

cell = row.createCell(10); //第十一个单元格

cell.setCellValue("支付渠道");

cell.setCellStyle(style);

cell = row.createCell(11); //第十二个单元格

cell.setCellValue("付款状态");

cell.setCellStyle(style);

ResponseData responseData = refundTicketDrawService.selectDrawPayFailList(drawPayFailDto);

List<DrawConfirmDetailVo> list = null;

if ("0".equals(responseData.getStatus())){

  list = (List<DrawConfirmDetailVo>) responseData.getData();

}

if (list != null && list.size() > 0){

   for (int i = 0; i < list.size(); i++){

     DrawConfirmDetailVo drawConfirmDetailVo = list.get(i); //创建行

    row = sheet.createRow(i+1); //创建单元格并且添加数据

    row.createCell(0).setCellValue(i+1);

    row.createCell(1).setCellValue(drawConfirmDetailVo.getApplyNo());

    row.createCell(2).setCellValue(drawConfirmDetailVo.getApplytime());

row.createCell(3).setCellValue(drawConfirmDetailVo.getRealName());

    row.createCell(4).setCellValue(drawConfirmDetailVo.getAccountNumber());

row.createCell(5).setCellValue(String.valueOf(drawConfirmDetailVo.getActualMoney()));

row.createCell(6).setCellValue(drawConfirmDetailVo.getBankName());

row.createCell(7).setCellValue(drawConfirmDetailVo.getBankAccount());

row.createCell(8).setCellValue(drawConfirmDetailVo.getFirstAuditPerson());

row.createCell(9).setCellValue(drawConfirmDetailVo.getSecondAuditPerson());

row.createCell(10).setCellValue(drawConfirmDetailVo.getPayChannel());

if (drawConfirmDetailVo.getPayState() == 0){

     row.createCell(11).setCellValue(PayState.Pay_wait.getDesc());

} else if (drawConfirmDetailVo.getPayState() == 1){

    row.createCell(11).setCellValue(PayState.Pay_success.getDesc());

   }else if (drawConfirmDetailVo.getPayState() == 2){

     row.createCell(11).setCellValue(PayState.Pay_fail.getDesc());

   }else if (drawConfirmDetailVo.getPayState() == 3){

    row.createCell(11).setCellValue(PayState.Pay_ing.getDesc());

}

}

}

  //web浏览通过MIME类型判断文件是excel类型

  response.setContentType("application/vnd.ms-excel;charset=utf-8");

  response.setCharacterEncoding("utf-8");

   //第六步将生成excel文件保存到指定路径下

   try { //FileOutputStream fout = new FileOutputStream("D:\\MediaPos.xls");

      String fileName = URLEncoder.encode("兑换提现付款失败表.xls");

     response.setHeader("Content-disposition", "attachment;filename=" + fileName);

     OutputStream fout = response.getOutputStream(); wb.write(fout); fout.close();

  } catch (IOException e) {

   logger.error("导出兑换提现付款失败表出错",e);

}

    return null;

}

POI导出,开发中经常会遇到数据导出这样的问题,下面是我在开发中采用的解决方法,大家可以参考,具体的实现害的结合你自身的业务逻辑的更多相关文章

  1. 【基于WinForm+Access局域网共享数据库的项目总结】之篇二:WinForm开发扇形图统计和Excel数据导出

    篇一:WinForm开发总体概述与技术实现 篇二:WinForm开发扇形图统计和Excel数据导出 篇三:Access远程连接数据库和窗体打包部署 [小记]:最近基于WinForm+Access数据库 ...

  2. AndroidStudio中利用git下载github或者git.oschina的代码时报错:repository test has failed解决方法

    作者:程序员小冰,CSDN博客:http://blog.csdn.net/qq_21376985 QQ986945193 微博:http://weibo.com/mcxiaobing AndroidS ...

  3. win7或win2008系统中,出现【已停止工作,联机检查解决方案并关闭该程序,关闭程序】解决方法!

    win7或win2008系统中,出现[已停止工作,联机检查解决方案并关闭该程序,关闭程序]解决方法! 经过摸索,点击[控制面板]-[操作中心]-[更改操作中心设置]-[问题报告设置]-[从不检查解决方 ...

  4. C# 实现将listview中已经显示的数据导出到Access 数据库

    private void button1_Click(object sender, EventArgs e) { OleDbConnection dbconn = new OleDbConnectio ...

  5. 分页(将数据库中的多条数据一页一页的显示在jsp页面中)

    一.显示数据库中的多条数据为什么要用分页 在真正的开发中,数据库中所存储的数据绝对不像我们平时所写的那样,仅仅有几条数据,而是有几十条甚至上百条,像淘宝京东的用户把都是上几十万甚至百万的.如果这时候在 ...

  6. C# 从集合A中取出集合B中不包含的数据(根据ID判断),并添加到集合B中

    从一个集合A中取出另一个集合B中不包含的数据,并添加到集合B中 private void button2_Click(object sender, EventArgs e) { var ListA = ...

  7. asp.net MVC中使用Html.Checkbox提示该字符串未被识别为有效的布尔值错误的解决方法

    在asp.net MVC中使用Html.CheckBox提交后出现该字符串未被识别为有效的布尔值错误,或从类型“System.String”到类型“System.Boolean”的参数转换失败. 错误 ...

  8. mysql数据库数据(字段数过大)太多导入不了的解决方法

    mysql数据库数据(字段数过大)太多导入不了的决方法: 1.打开navicat 工具 2.在数据库上右键,执行右键菜单命令“命令列界面” 3.在打开的窗口中,运行set global max_all ...

  9. 数据库查询的数据导出到xls表,集合数据导出到xls表

    //实体类package com.outxls; public class Student { private Integer studentId; private String studentNam ...

随机推荐

  1. mysql 用 group by 和 order by同时使用

    首先,这是不可能实现的 mysql的查询的顺序 select -> from-> where->group by->having->order by. 但mysql的解析 ...

  2. camshift.py OpenCv例程阅读

    源码在这 #!/usr/bin/env python ''' Camshift tracker ================ This is a demo that shows mean-shif ...

  3. scanf()和scanf_s()

    在最初的C语言中,原版的输入就是scanf("<格式化字符串>",<地址表>) ANSI C中没有scanf_s(),只有scanf(),scanf()在读 ...

  4. 跟我一起玩Win32开发(17):启动和结束进程

    这里我再次说明一下,我不知道为什么,现在的人那么喜欢走极端,估计是价值观都“升级”了的缘故吧. 我撰写这一系列Win32相关的文章,并不是叫大家一定要用Win32去开发项目,仅仅是给大家了解一下,Wi ...

  5. 洛谷 P3327 [SDOI2015]约数个数和 || Number Challenge Codeforces - 235E

    https://www.luogu.org/problemnew/show/P3327 不会做. 去搜题解...为什么题解都用了一个奇怪的公式?太奇怪了啊... 公式是这样的: $d(xy)=\sum ...

  6. 并查集 HDOJ 1232 畅通工程

    题目传送门 /* 并查集(Union-Find)裸题 并查集三个函数:初始化Init,寻找根节点Find,连通Union 考察:连通边数问题 */ #include <cstdio> #i ...

  7. PDO相关函数

    (PHP 5 >= 5.1.0, PHP 7, PECL pdo >= 0.1.0) PDO::__construct — 创建一个表示数据库连接的 PDO 实例 说明 PDO::__co ...

  8. [转]VC++中对文件的写入和读取

    本文转自:http://blog.csdn.net/fanghb_1984/article/details/7425705 本文介绍两种方法对文件进行读取和写入操作:1.采用fstream类:2.采用 ...

  9. Spring数据访问1 - 数据源配置及数据库连接池的概念

    无论你要选择哪种数据访问方式,首先你都需要配置好数据源引用. Spring中配置数据源的几种方式 通过在JDBC驱动程序定义的数据源: 通过JNDI查找的数据源: 连接池的数据源: 对于即将发布到生产 ...

  10. 【学习笔记】一:JavaScript简介

    1.JavaScript简史 1)JavaScript最初的功能只是用来在客户端做简单的输入验证器,减少客户端与服务器端的数据交互(毕竟那个年代网速有限). 2)JavaScript的飞速发展及Net ...