@RequestMapping(value = "/exportFncCollectReport")
public void exportFncCollectReport(QueryFncCollectVO queryVo, HttpServletResponse response, HttpServletRequest request) {
String date = DateUtil.dateToString(new Date(), "yyyy-MM-dd");
String fileName = "xxx报表数据" + date + ".xls";
try {
response.reset();
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition",
"attachment; filename=" + (request.getHeader("User-Agent").toLowerCase().indexOf("firefox") > 0
? new String(fileName.getBytes("utf-8"), "iso8859-1")
: URLEncoder.encode(fileName, "UTF-8")));
List<List<Object>> allData = new ArrayList<List<Object>>();
List<Object> head = new ArrayList<Object>();
String[] heads = { "xxx","xxx", "xxx", "xxx", "xxx", "xxx", "xxx",};
head.addAll(Arrays.asList(heads));
allData.add(head);
List<Object> rowMeta;
PageParam pageParam = new PageParam();
PageInfo<FncCollectReportResultVO> pg = fncCollectApi.findFncCollectReportPage(queryVo, pageParam);
List<FncCollectReportResultVO> pglist = pg.getList();
for (FncCollectReportResultVO vo : pglist) {
rowMeta = new ArrayList<Object>();
rowMeta.add(vo.getFncCollectId());
rowMeta.add(vo.getReceiptCollectId());
rowMeta.add(vo.getPayCstNm());
rowMeta.add(vo.getCtrNm());
rowMeta.add(vo.getCtrId());
rowMeta.add(vo.getProNm());
if(vo.getFncStDt()!=null) {
rowMeta.add(new SimpleDateFormat("yyyy-MM-dd").format(vo.getFncStDt()));
}
if(vo.getFncEndDt()!=null) {
rowMeta.add(new SimpleDateFormat("yyyy-MM-dd").format(vo.getFncEndDt()));
}
allData.add(rowMeta);
}
//ExcelUtil_jxl.writeExcel(response.getOutputStream(), allData, "xxx报表数据");
ExcelUtil_poi.export(response, allData, "xxx报表数据");
response.flushBuffer();
} catch (Exception e) {
e.printStackTrace();
}
}
报表导出到表格
最新推荐文章于 2022-08-24 14:15:17 发布