[alibaba/easyexcel]导出文件打开报错

2024-05-23 82 views
5

异常代码

    String fileName = "Withdrawals agency record " + model.getCreateTime().split(" ")[0]+ "_" + model.getReturnTime().split(" ")[0] + ".xlsx";
//            _response.setContentType("multipart/form-data");
            _response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
            _response.setContentType("application/vnd.ms-excel");
            _response.setCharacterEncoding("utf-8");
            ExcelWriter writer = new ExcelWriter(out, ExcelTypeEnum.XLSX);
            Sheet sheet = new Sheet(1, 1, AgencyWithdrawExport.class);
            sheet.setSheetName(fileName);
            //写出数据
            writer.write(createModelList(
                    model.getUuid(),
                    model.getAgencyId(),
                    model.getAuditStatus(),
                    model.getUid(),
                    model.getLevel(),
                    model.getCreateTime(),
                    model.getReturnTime()), sheet);
            writer.finish();
            out.close();

回答

1

有没有排除过 后台使用 .xlsx 导出,前端使用 .xls

5

这个是直接导出的,没有使用前端。后端直接_response这个连接下载到本地

2

直接使用浏览器,且方法的返回设置void