easyExcel 导出多sheet页

方法入参

 exportList(HttpServletResponse response)

文件生成逻辑写入

response.setContentType("application/vnd.ms-excel");
		response.setCharacterEncoding("utf-8");
		try {
			String fileName = URLEncoder.encode("template", "UTF-8");
			response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
			ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build();
			WriteSheet mainSheet = EasyExcel.writerSheet(0, "采购单").head(FtbResponseDto.class).build();
			excelWriter.write(map,mainSheet);
			WriteSheet detailSheet = EasyExcel.writerSheet(1, "采购单明细").head(FtbResponseDto.class).build();
			excelWriter.write(map,detailSheet);
			excelWriter.finish();
		} catch (IOException e) {
			e.printStackTrace();
		}

需要注意的是sheet页名称不能相同

导出实体注解说明

	@ExcelIgnore     // 隐藏字段
    private String feedbackId;
    @ExcelProperty(value = "问题原因")  // 列名
    private String reason;

未测试实体注解

	@DateTimeFormat("yyyy年MM月dd日HH时mm分ss秒")   // 日期格式
    private Date date;
    @NumberFormat("#.##%")    // 百分比显示   例如责任比例需要显示百分比
    private Date date;
    private Double doubleData;

你可能感兴趣的:(java)