Skip to content

Commit

Permalink
升级easypoi到v4.1.0,并解决poi包冲突问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zlt2000 committed Aug 12, 2019
1 parent d857cc1 commit c72aeaa
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 30 deletions.
25 changes: 10 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
<mybatis-plus-boot-starter.version>3.1.2</mybatis-plus-boot-starter.version>
<aliyun-sdk-oss>3.4.2</aliyun-sdk-oss>
<qiniu-java-sdk>7.2.18</qiniu-java-sdk>
<easypoi.version>4.0.0</easypoi.version>
<easypoi.version>4.1.0</easypoi.version>
<poi.version>4.1.0</poi.version>
<spring-boot-admin.version>2.0.6</spring-boot-admin.version>
<velocity.version>1.7</velocity.version>
<commons-configuration.version>1.10</commons-configuration.version>
Expand Down Expand Up @@ -225,26 +226,20 @@
<artifactId>qiniu-java-sdk</artifactId>
<version>${qiniu-java-sdk}</version>
</dependency>
<!-- easypoi -->
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>${easypoi.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>${easypoi.version}</version>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<!-- easypoi -->
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<artifactId>easypoi-base</artifactId>
<version>${easypoi.version}</version>
</dependency>
<dependency>
Expand Down
9 changes: 0 additions & 9 deletions zlt-business/user-center/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@
<artifactId>mysql-connector-java</artifactId>
</dependency>

<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
</dependency>

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions zlt-commons/zlt-common-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
<artifactId>spring-cloud-starter-openfeign</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<!-- easypoi -->
<dependency>
<groupId>cn.afterturn</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private 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);

Expand All @@ -61,7 +61,7 @@ public static void exportExcel(List<?> list, String title, String sheetName, Cla
*/
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));
}

/**
Expand Down Expand Up @@ -93,7 +93,7 @@ private static void defaultExport(List<Map<String, Object>> list, String fileNam

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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ <h2 class="header-title">用户管理</h2>
$('#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;
Expand Down

0 comments on commit c72aeaa

Please sign in to comment.