Java的 Excel 读写--easyexcel
https://www.cnblogs.com/TFengStorm/p/11776893.html
@GetMapping("/out")
public void out(HttpServletResponse response) throws Exception {
String fileName = new String(("temp.xlsx").getBytes("UTF-8"), "ISO-8859-1");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
response.setContentType("application/force-download");// 设置强制下载不打开
/* String tt = "D:\\work\\temp.xlsx";
OutputStream out = new FileOutputStream(tt);*/
ExcelWriter writer = new ExcelWriter(response.getOutputStream(), ExcelTypeEnum.XLSX,true);
Sheet sheet = new Sheet(1,1,ReadModel.class);
sheet.setSheetName("学生信息");
List<ReadModel> datas = new ArrayList<>();
ReadModel readModel1 = new ReadModel();
ReadModel readModel2 = new ReadModel();
readModel1.setStudentName("张三");
readModel2.setStudentName("李四");
datas.add(readModel1);
datas.add(readModel2);
writer.write(datas,sheet);
writer.finish();
}