first commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.starry.admin.utils;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
public class ExcelUtils {
|
||||
|
||||
public static List<?> importEasyExcel(InputStream is, Class<?> pojoClass) {
|
||||
return EasyExcel.read(is).head(pojoClass).sheet().doReadSync();
|
||||
}
|
||||
|
||||
public static void exportEasyExcel(HttpServletResponse response, Class<?> pojoClass, List<?> list, String sheetName) {
|
||||
try {
|
||||
EasyExcel.write(response.getOutputStream(), pojoClass).sheet(sheetName).doWrite(list);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user