This commit is contained in:
77
2024-07-21 15:01:09 +08:00
parent f98988f708
commit d11d10f1bf
5 changed files with 128 additions and 4 deletions

View File

@@ -45,6 +45,10 @@ public class ExcelUtil {
return EasyExcel.read(is).head(clazz).autoCloseStream(false).sheet().doReadSync();
}
public static <T> List<T> importExcel(InputStream is, Class<T> clazz,String sheetName) {
return EasyExcel.read(is).head(clazz).autoCloseStream(false).sheet(sheetName).doReadSync();
}
/**
* 使用校验监听器 异步导入 同步返回
@@ -306,7 +310,7 @@ public class ExcelUtil {
/**
* 重置响应体
*/
private static void resetResponse(String sheetName, HttpServletResponse response) throws UnsupportedEncodingException {
public static void resetResponse(String sheetName, HttpServletResponse response) throws UnsupportedEncodingException {
String filename = encodingFilename(sheetName);
FileUtils.setAttachmentResponseHeader(response, filename);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");