当前位置: 首页 > 工具软件 > WriteExcel > 使用案例 >

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);
        }
    }

相关阅读

相关文章

相关问答