writeExcel
漆雕疏珂
2023-12-01
public static void writeExcelToResponse(Workbook workbook, String fileName, HttpServletResponse response) throws IOException {
logger.info("writeExcelToResponse() start:[{}]" , fileName);
try {
OutputStream output=response.getOutputStream();
response.reset();
response.setHeader("Content-disposition","attachment;filename="+new String(fileName.getBytes()));
response.setContentType("Content-Type:application/vnd.ms-excel");
workbook.write(output);
output.flush();
output.close();
} catch (Exception e) {
logger.error("writeExcel异常" , e);
}
}