/**
* 退票导出excel
* @param
* @return
*/
@GetMapping("/export")
@ResponseBody
public Map<String, Object> export(HttpServletRequest request, HttpServletResponse response, RefundReq req) throws IOException {
logger.info("refunded invoice get params : " + JsonUtils.toJson(req));
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
// 防止中文乱码
String fileName = URLEncoder.encode("行业退票列表", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xls");
Map<String, Object> resultMap = new HashMap<>();
try {
List<TRefundInvoice> exportList = refundInvoiceService.getExportList(req);
List<RefundExportVo> dataList = new ArrayList<>(exportList.size());
for (int i = 0; i < exportList.size(); i++) {
RefundExportVo excelRow = new RefundExportVo();
excelRow.setId(exportList.get(i).getId());
excelRow.setInvoiceNo(exportList.get(i).getInvoiceNo());
//excelRow.setInvoiceType(exportList.get(i).getInvoiceType());
excelRow.setInvoiceAmount(exportList.get(i).getInvoiceAmount());
excelRow.setRefundResonContent(exportList.get(i).getRefundResonContent());
excelRow.setStatus(exportList.get(i).getStatus());
excelRow.setCreateTime(exportList.get(i).getCreateTime());
dataList.add(excelRow);
}
EasyExcel.write(response.getOutputStream(), RefundExportVo.class).sheet("退票列表").doWrite(dataList);
resultMap.put("code", 0);
resultMap.put("msg", "导出成功 ! ");
return resultMap;
} catch (IOException e) {
logger.error("RefundInvoice export exception... " + e);
resultMap.put("code", 1);
resultMap.put("msg", "导出失败 ");
}
return resultMap;
}
页面表格导出Excel表格
最新推荐文章于 2023-09-06 12:04:15 发布
本文介绍了一种通过Java Spring Boot框架实现的退票信息批量导出至Excel的方法。该方法利用EasyExcel库将数据库中获取的退票记录转换为Excel文件格式,支持中文文件名及内容的正确显示,确保了数据导出过程的高效性和准确性。
2068

被折叠的 条评论
为什么被折叠?



