public static void exportExcel(HttpServletResponse response, String fileName, Class head, List list){
try {
response.setContentType("application/octet-stream;charset=UTF-8");
response.setHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(fileName, "UTF-8"));
EasyExcel.write(response.getOutputStream(), head).sheet("sheet").doWrite(list);
} catch (IOException e) {
e.printStackTrace();
}
}
@Data
public class ExportScrapDTO implements Serializable {
@ExcelProperty(value = "条码号", index = 0)
private String barcode;
@ExcelProperty(value = "题名", index = 1)
private String title;
@ExcelProperty(value = "装订卷期", index = 2)
private String bindingDate;
@NumberFormat("#.##")
@ExcelProperty(value = "价格", index = 3)
private BigDecimal price;
@ExcelProperty(value = "issn", index = 4)
private String issn;
@ExcelProperty(value = "统一刊号", index = 5)
private String periodicalNumber;
@ExcelProperty(value = "邮发代号", index = 6)
private String mailCode;
@ExcelProperty(value = "分类号", index = 7)
private String classNumber;
@ExcelProperty(value = "书次号", index = 8)
private String bookNumber;
@ExcelProperty(value = "索取号", index = 9)
private String requestNumber;
@ExcelProperty(value = "出版社", index = 10)
private String publisher;
@ExcelProperty(value = "出版年份", index = 11)
private String publicationYear;
@ExcelProperty(value = "馆藏地", index = 12)
private String holdingSite;
@ExcelProperty(value = "馆藏状态", index = 13)
private String holdingStatus;
@ExcelProperty(value = "报废时间", index = 14)
private String updateTime;
}
异常提示 没有异常显示 建议描述 返回正常 前端其他接口也是这样 就这个导出excel文件 打不开 其他都是正常的