package com.huimv.management.util;


import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * <p>
 * Excel工具类
 * </p>
 *
 * @author yinhao
 * @date 2021/6/29 16:44
 */
public class ExportUtil {

    public static <T> ModelAndView buildModelAndView(String fileName, Class<T> className, String title, List<T> dataList) {
        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
        mv.addObject(NormalExcelConstants.FILE_NAME, fileName);
        mv.addObject(NormalExcelConstants.CLASS, className);
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams(title,"导出信息"));
        mv.addObject(NormalExcelConstants.DATA_LIST, dataList);
        return mv;
    }
}
