public void exportTemp(String fileName, String sheetName, Class<?> clz, HttpServletResponse response) throws Exception {
response.addHeader("Content-Disposition", String.format("attachment;fileName=\"%s\"", new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1)));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
OutputStream out = response.getOutputStream();
ExcelWriter excelWriter = EasyExcel.write(out, clz).build();
WriteSheet writeSheet = EasyExcel.writerSheet(sheetName).build();
excelWriter.write(null, writeSheet);
excelWriter.finish();
out.flush();
out.close();
}
Java EasyExcel导出Excel模版
最新推荐文章于 2024-07-04 10:12:09 发布