27 lines
752 B
Java
27 lines
752 B
Java
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());
|
|
}
|
|
}
|
|
}
|