springboot集成easypoi导出多sheet页

pom文件


	cn.afterturn
	easypoi-base
	4.1.0

导出模板:

springboot集成easypoi导出多sheet页_第1张图片

后端代码示例:

/**
     * 导出加油卡进便利店大额审批列表
     * @throws IOException 
     */
    @PreAuthorize("@ss.hasPermi('card:large:export')")
    @Log(title = "加油卡进便利店大额审批", businessType = BusinessType.EXPORT)
    @GetMapping("/exportByTemp/{ids}")
    public AjaxResult exportByTemp(HttpServerResponse response, @PathVariable Long[] ids) throws IOException
    {
    	TemplateExportParams params = new TemplateExportParams("templates/excel/加油卡进便利店大额审批-导出.xlsx",true);
    	Map>> sheetsMap = new HashMap<>();
    	try {
    		int i = 0;
    		for (Long id : ids) {
    			List> list = new ArrayList<>();
        		Map map = new HashMap();
            	ApprovalprocessCardLarge selectApprovalprocessCardLargeById = approvalprocessCardLargeService.selectApprovalprocessCardLargeById(id);
            	map.put("stationProcess", selectApprovalprocessCardLargeById.getStationProcess());
            	map.put("countyProcess", selectApprovalprocessCardLargeById.getCountyProcess());
            	map.put("cityProcess", selectApprovalprocessCardLargeById.getCityProcess());
            	List detailByLargeId = approvalprocessCardLargeDetailService.getDetailByLargeId(id);
            	
            	map.put("largeList", detailByLargeId);
            	Date reportDate = selectApprovalprocessCardLargeById.getReportDate();
            	String parseDateToStr = DateUtils.parseDateToStr("yyyy-MM-dd", reportDate);
            	map.put("date", parseDateToStr);
            	
            	list.add(map);
            	sheetsMap.put(i++,list);
    		}
        	
    		Workbook wb = ExcelExportUtil.exportExcelClone(sheetsMap, params);
        	FileOutputStream out = new FileOutputStream(StringUtils.getAbsoluteFile("加油卡进便利店大额审批.xlsx"));
    		wb.write(out);
    		IOUtils.closeQuietly(wb);
    		IOUtils.closeQuietly(out);
		} catch (Exception e) {
			logger.error("加油卡进便利店大额审批下载失败--->" + e.getMessage());
		}
    	return AjaxResult.success("加油卡进便利店大额审批.xlsx");
    }

导出效果:

springboot集成easypoi导出多sheet页_第2张图片

springboot集成easypoi导出多sheet页_第3张图片

springboot集成easypoi导出多sheet页_第4张图片

你可能感兴趣的:(spring,boot,java,后端)