EasyExcel通过模板导出数据
大家好,这两天在做excel导出功能,使用的是easyExcel,不得不说其功能全面,很好入手。
但是在开发的过程中也会遇到一些文档里无法提供解决的问题,这里我分享代码,方便以后自己观看,也希望能帮到想要导出功能的童鞋。
easy excel官网入口.
JAVA 导出 EXCEL入口
注: 大家好,今天更新内容:eastExcel 使用模板下载,本地正常下载,但是发布到服务器上遇到一个一些问题,
目前抽空在看看解决方法,再最下面贴出来希望有大佬看到能指点一二,小弟在这里先谢过了。
我又换了一个方法去实现通过模板下载excel功能
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.0-beta1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
@Override
public void exportInfo(List<CustomerInfo> customerDealerInfo, HttpServletResponse response) throws IOException {
OutputStream out = null;
BufferedOutputStream bos = null;
try {
String templateFileName = FileUtil.getPath() + "templates" + File.separator + "模板.xls";
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("下载后的名称.xls", "utf-8");
response.setHeader("Content-disposition", "attachment; filename=" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1"));
out = response.getOutputStream(