@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;
}
}
@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;
}
}