package com.starry.admin.utils;

import com.alibaba.excel.EasyExcel;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

/**
 * @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());
        }
    }
}
