From 5d73bc771f19bb2b307868064613ce489ed18e1e Mon Sep 17 00:00:00 2001 From: duandazhi Date: Mon, 15 Mar 2021 23:23:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E7=9A=84mimetype,=20=E7=9B=AE=E5=89=8Dexcel=20mimetype?= =?UTF-8?q?=E6=98=AF=20doc,=E5=85=BC=E5=AE=B9=E6=80=A7=E6=AF=94=E8=BE=83?= =?UTF-8?q?=E5=B7=AE=E5=9C=A8macos=20=E4=B8=8B=E8=BD=BDexcel=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9B=B4=E6=8E=A5=E5=8F=98=E6=88=90=E4=BA=86=20xlw?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BA=86=EF=BC=8C=E5=BB=BA=E8=AE=AE=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=20excel=20mimetype=20=E5=88=B0=20excel2007=20+=20;=20?= =?UTF-8?q?=E8=AF=A6=E8=A7=A3=EF=BC=9Adocx=E3=80=81xlsx=20=E8=BF=99?= =?UTF-8?q?=E7=A7=8D=20office=202007=20=E6=A0=BC=E5=BC=8F=20=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=20MIME?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java index f754a2ca..68cbb6bf 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java @@ -322,6 +322,7 @@ public class ExcelUtil public void exportExcel(HttpServletResponse response, List list, String sheetName) throws IOException { response.setContentType("application/vnd.ms-excel"); + //response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); this.init(list, sheetName, Type.EXPORT); exportExcel(response.getOutputStream()); @@ -335,7 +336,8 @@ public class ExcelUtil */ public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException { - response.setContentType("application/vnd.ms-excel"); + //response.setContentType("application/vnd.ms-excel"); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); this.init(null, sheetName, Type.IMPORT); exportExcel(response.getOutputStream()); From e8deeae4a92be080f820f39a997d1563246e960b Mon Sep 17 00:00:00 2001 From: duandazhi Date: Mon, 15 Mar 2021 23:24:26 +0800 Subject: [PATCH 2/2] mime type fix --- .../main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java index 68cbb6bf..95c73be9 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java @@ -321,8 +321,8 @@ public class ExcelUtil */ public void exportExcel(HttpServletResponse response, List list, String sheetName) throws IOException { - response.setContentType("application/vnd.ms-excel"); - //response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + //response.setContentType("application/vnd.ms-excel"); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); this.init(list, sheetName, Type.EXPORT); exportExcel(response.getOutputStream());