1. 完成用户导入的功能

This commit is contained in:
YunaiV
2021-01-15 19:52:24 +08:00
parent c3df5bc62f
commit 4ab1cf1cd4
13 changed files with 152 additions and 137 deletions

View File

@ -2,6 +2,7 @@ package cn.iocoder.dashboard.framework.excel.core.util;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -38,4 +39,10 @@ public class ExcelUtils {
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
}
public static <T> List<T> raed(MultipartFile file, Class<T> head) throws IOException {
return EasyExcel.read(file.getInputStream(), head, null)
.autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理
.doReadAllSync();
}
}