From c72aeaadb3fa951375bd309eec1d37a57fd11751 Mon Sep 17 00:00:00 2001 From: zlt Date: Mon, 12 Aug 2019 23:29:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7easypoi=E5=88=B0v4.1.0?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E8=A7=A3=E5=86=B3poi=E5=8C=85=E5=86=B2?= =?UTF-8?q?=E7=AA=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 25 ++++++++----------- zlt-business/user-center/pom.xml | 9 ------- .../com/central/user/model/SysUserExcel.java | 2 +- .../zlt-common-spring-boot-starter/pom.xml | 8 ++++++ .../com/central/common/utils/ExcelUtil.java | 6 ++--- .../resources/static/pages/system/user.html | 4 +-- 6 files changed, 24 insertions(+), 30 deletions(-) diff --git a/pom.xml b/pom.xml index 1aed98d..f7420c9 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,8 @@ 3.1.2 3.4.2 7.2.18 - 4.0.0 + 4.1.0 + 4.1.0 2.0.6 1.7 1.10 @@ -225,26 +226,20 @@ qiniu-java-sdk ${qiniu-java-sdk} - - cn.afterturn - easypoi-base - ${easypoi.version} - - - com.google.guava - guava - - + org.apache.poi + poi + ${poi.version} - cn.afterturn - easypoi-web - ${easypoi.version} + org.apache.poi + poi-ooxml + ${poi.version} + cn.afterturn - easypoi-annotation + easypoi-base ${easypoi.version} diff --git a/zlt-business/user-center/pom.xml b/zlt-business/user-center/pom.xml index edbef36..e6361cc 100644 --- a/zlt-business/user-center/pom.xml +++ b/zlt-business/user-center/pom.xml @@ -63,15 +63,6 @@ mysql-connector-java - - cn.afterturn - easypoi-web - - - cn.afterturn - easypoi-annotation - - io.micrometer micrometer-registry-prometheus diff --git a/zlt-business/user-center/src/main/java/com/central/user/model/SysUserExcel.java b/zlt-business/user-center/src/main/java/com/central/user/model/SysUserExcel.java index d406fdd..aae7e28 100644 --- a/zlt-business/user-center/src/main/java/com/central/user/model/SysUserExcel.java +++ b/zlt-business/user-center/src/main/java/com/central/user/model/SysUserExcel.java @@ -24,7 +24,7 @@ public class SysUserExcel implements Serializable { @Excel(name = "手机号码", height = 20, width = 30, isImportField = "true_st") private String mobile; - @Excel(name = "学生性别", replace = { "男_0", "女_1" }, suffix = "生", isImportField = "true_st") + @Excel(name = "性别", replace = { "男_0", "女_1" }, isImportField = "true_st") private Integer sex; @Excel(name = "创建时间", format = CommonConstant.DATETIME_FORMAT, isImportField = "true_st", width = 20) diff --git a/zlt-commons/zlt-common-spring-boot-starter/pom.xml b/zlt-commons/zlt-common-spring-boot-starter/pom.xml index 2f20cb2..71a3e87 100644 --- a/zlt-commons/zlt-common-spring-boot-starter/pom.xml +++ b/zlt-commons/zlt-common-spring-boot-starter/pom.xml @@ -54,6 +54,14 @@ spring-cloud-starter-openfeign true + + org.apache.poi + poi + + + org.apache.poi + poi-ooxml + cn.afterturn diff --git a/zlt-commons/zlt-common-spring-boot-starter/src/main/java/com/central/common/utils/ExcelUtil.java b/zlt-commons/zlt-common-spring-boot-starter/src/main/java/com/central/common/utils/ExcelUtil.java index 210a66a..6c89841 100644 --- a/zlt-commons/zlt-common-spring-boot-starter/src/main/java/com/central/common/utils/ExcelUtil.java +++ b/zlt-commons/zlt-common-spring-boot-starter/src/main/java/com/central/common/utils/ExcelUtil.java @@ -42,7 +42,7 @@ public class ExcelUtil { */ public static void exportExcel(List list, String title, String sheetName, Class pojoClass, String fileName , boolean isCreateHeader, HttpServletResponse response) throws IOException { - ExportParams exportParams = new ExportParams(title, sheetName); + ExportParams exportParams = new ExportParams(title, sheetName, ExcelType.XSSF); exportParams.setCreateHeadRows(isCreateHeader); defaultExport(list, pojoClass, fileName, response, exportParams); @@ -61,7 +61,7 @@ public class ExcelUtil { */ public static void exportExcel(List list, String title, String sheetName, Class pojoClass, String fileName , HttpServletResponse response) throws IOException { - defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName)); + defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName, ExcelType.XSSF)); } /** @@ -93,7 +93,7 @@ public class ExcelUtil { private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) throws IOException { response.setCharacterEncoding("UTF-8"); - response.setHeader("content-Type", "application/vnd.ms-excel"); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); workbook.write(response.getOutputStream()); } diff --git a/zlt-web/back-web/src/main/resources/static/pages/system/user.html b/zlt-web/back-web/src/main/resources/static/pages/system/user.html index 1cab116..91886db 100644 --- a/zlt-web/back-web/src/main/resources/static/pages/system/user.html +++ b/zlt-web/back-web/src/main/resources/static/pages/system/user.html @@ -150,12 +150,12 @@ $('#user-btn-export').click(function () { var url = config.base_server + 'api-user/users/export?access_token='+config.getToken().access_token; var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); + xhr.open('POST', url, true); xhr.responseType = "blob"; xhr.setRequestHeader("client_type", "DESKTOP_WEB"); xhr.onload = function() { if (this.status == 200) { - var fileName = "user.xls"; + var fileName = "user.xlsx"; var blob = this.response; var a = document.createElement('a'); a.innerHTML = fileName; -- GitLab