大数据的导出,百万条等

@SuppressWarnings("unused")
@RequestMapping(params = "excelExport")
public void excelExport(@RequestParam HashMap<String, Object> paramMap, HttpServletRequest request,HttpServletResponse response) {
response.setContentType("application/vnd.ms-excel");
String codedFileName = null;
OutputStream fOut = null;
HttpSession session = request.getSession();
try {
codedFileName = "代付信息";
// 根据浏览器进行转码,使其支持中文文件名
if (BrowserUtils.isIE(request)) {
response.setHeader("content-disposition","attachment;filename=" + java.net.URLEncoder.encode(codedFileName,"UTF-8") + ".xls");
} else {
String newtitle = new String(codedFileName.getBytes("UTF-8"),"ISO8859-1");
response.setHeader("content-disposition","attachment;filename=" + newtitle + ".xlsx");
}
// 产生工作簿对象
SXSSFWorkbook workbook = null;
if(request.getSession().getAttribute("userType").equals("002")){
paramMap.put("merchantId", request.getSession().getAttribute("companyId"));
}else if(request.getSession().getAttribute("userType").equals("003")){
paramMap.put("orgId", request.getSession().getAttribute("companyId"));
}
List<Withdrawal> dataList = withdrawalService.getByCondition(paramMap);
workbook = exportExcel("代付信息", dataList);
fOut = response.getOutputStream();
workbook.write(fOut);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fOut.flush();
fOut.close();
} catch (IOException e) {


}
}
}

public  SXSSFWorkbook exportExcel(String sheetName, List<Withdrawal> dataList) {
SXSSFWorkbook workbook = new SXSSFWorkbook();
        Sheet sheet = workbook.createSheet(sheetName);  
        CellStyle titleStyle = ExcelUtil.getTitleStyle(workbook);
        Row row = sheet.createRow((int) 0);  
        row.setHeight((short) 900);
        Cell cell = null;
        
        int i = 0;
        cell = row.createCell(i++);
        cell.setCellValue("产品标识"); 
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("商品类型"); 
        cell.setCellStyle(titleStyle);
        cell = row.createCell(i++);
        cell.setCellValue("订单状态"); 
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("实际提现费"); 
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("订单编码"); 
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("金额"); 
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("商户编码"); 
        cell.setCellStyle(titleStyle);        
        cell = row.createCell(i++);
        cell.setCellValue("商户名称"); 
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("通道名称");
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("帐户名"); 
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("卡号"); 
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("联行号"); 
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("银行名称"); 
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("电话号码"); 
        cell.setCellStyle(titleStyle); 
        cell = row.createCell(i++);
        cell.setCellValue("交易时间"); 
        cell.setCellStyle(titleStyle); 
        int b = 1;
        HashMap<String, Object> paramMap1=new HashMap<String, Object>();
    paramMap1.put("tab_name","ORDER_INFO");
    paramMap1.put("col_name","STATE");
    HashMap<String, String>  stateMap =sysCommonService.noteDict(paramMap1);
        for(Withdrawal data : dataList) {
        row = sheet.createRow(b); 
       int a = 0;
        row.createCell(a++).setCellValue(data.getGoodsId());
        row.createCell(a++).setCellValue(data.getGoodsType());
        row.createCell(a++).setCellValue(stateMap.get(data.getState()));
        row.createCell(a++).setCellValue(data.getFeeValue());
        row.createCell(a++).setCellValue(data.getOrderCode());
        row.createCell(a++).setCellValue(data.getAmount());
        row.createCell(a++).setCellValue(data.getMerchantCode());
        row.createCell(a++).setCellValue(data.getMerchantName());
        row.createCell(a++).setCellValue(data.getChannelName());
        row.createCell(a++).setCellValue(data.getAccountName());
        row.createCell(a++).setCellValue(data.getAccountNbr());
        row.createCell(a++).setCellValue(data.getBankType());
        row.createCell(a++).setCellValue(data.getBankName());
        row.createCell(a++).setCellValue(data.getPhone());
        row.createCell(a++).setCellValue(data.getCreateDt());
        b++;
        }


        for(int a = 0; a < i; a++){
            sheet.autoSizeColumn(a); 
        }
        
return workbook;
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值