修改poi的包名
可以查看我这篇文章https://blog.csdn.net/qq_23888451/article/details/123408956
打包到本地仓库
mvn install:install-file -Dfile=my-poi-4.1.2.jar -DgroupId=com.yootii -DartifactId=poi -Dversion=4.1.2 -Dpackaging=jar
mvn install:install-file -Dfile=my-poi-ooxml-4.1.2.jar -DgroupId=com.yootii -DartifactId=poi-ooxml -Dversion=4.1.2 -Dpackaging=jar
mvn install:install-file -Dfile=my-poi-schemas-4.1.2.jar -DgroupId=com.yootii -DartifactId=poi-ooxml-schemas -Dversion=4.1.2 -Dpackaging=jar
重新编译打包easyExcel
下载源码
https://github.com/alibaba/easyexcel
修改pom依赖
<dependency>
<groupId>com.my</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>com.my</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>com.my</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.21</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>3.1.0</version>
</dependency>
修改项目groupId
修改import名称
编译打包
mvn packge 将jar包加入本地仓库
mvn install:install-file -Dfile=easyexcel-3.0.5.jar -DgroupId=com.my -DartifactId=easyexcel -Dversion=3.0.5 -Dpackaging=jar
使用
pom文件
<dependency>
<groupId>com.my</groupId>
<artifactId>easyexcel</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>com.my</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>com.my</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>com.my</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.21</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>3.1.0</version>
</dependency>
Excelutil类
package com.zz.util;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.util.ListUtils;
import java.util.Date;
import java.util.List;
public class EasyExcelUtil {
private static List<List<Object>> dataList() {
List<List<Object>> list = ListUtils.newArrayList();
for (int i = 0; i < 100; i++) {
List<Object> data = ListUtils.newArrayList();
data.add("字符串" + i);
data.add(new Date());
data.add(0.56);
list.add(data);
}
return list;
}
public static void noModelWrite2() {
String fileName = "d:/doc/noModelWrite" + System.currentTimeMillis() + ".xlsx";
EasyExcel.write(fileName).head(head()).sheet("模板").doWrite(dataList());
}
private static List<List<String>> head() {
List<List<String>> list = ListUtils.newArrayList();
List<String> head0 = ListUtils.newArrayList();
head0.add("字符串" + System.currentTimeMillis());
List<String> head1 = ListUtils.newArrayList();
head1.add("数字" + System.currentTimeMillis());
List<String> head2 = ListUtils.newArrayList();
head2.add("日期" + System.currentTimeMillis());
list.add(head0);
list.add(head1);
list.add(head2);
return list;
}
public static void main(String[] args) {
long startTime = System.currentTimeMillis();
noModelWrite2();
System.out.println(System.currentTimeMillis() - startTime);
}
}
自定义的easyexcel-3.0.5.jar,我上传到云盘上了,如果用可以直接拿去用
链接:https://pan.baidu.com/s/1JPBEuByEv_PHkRxD3_MDxQ
提取码:jv8v
|