diff --git a/dbswitch-admin-ui/src/views/task/assignment.vue b/dbswitch-admin-ui/src/views/task/assignment.vue index 3fccc919..a8f79b09 100644 --- a/dbswitch-admin-ui/src/views/task/assignment.vue +++ b/dbswitch-admin-ui/src/views/task/assignment.vue @@ -6,7 +6,7 @@ 停止   |   - 导入任务 + 导入任务 导出任务 void write(HttpServletResponse response, Class clazz, List list, String fileName, + String sheetName) { + + try { + // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman + // response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("utf-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); + // response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + response.setHeader("Cache-Control", "no-cache"); + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); + EasyExcel.write(response.getOutputStream(), clazz) + .sheet(sheetName) + .doWrite(list); + } catch (IOException ex) { + throw new DbswitchException(ResultCode.ERROR_INTERNAL_ERROR, ex.getMessage()); + } + + } +} diff --git a/pom.xml b/pom.xml index 7fe820dc..475461b8 100644 --- a/pom.xml +++ b/pom.xml @@ -134,12 +134,6 @@ 3.3.4 - - org.mapstruct - mapstruct - 1.4.2.Final - -