无关风月
昨天 02bb94e413f6950b9786c5ee86c0937bc20f8ae8
ruoyi-system/src/main/java/com/ruoyi/system/utils/ExcelPoiUtils.java
@@ -9,6 +9,7 @@
import cn.hutool.core.util.ReflectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.ruoyi.system.vo.system.ProjectDeptDetailsChildVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils;
@@ -62,7 +63,16 @@
            downloadExcelEntityDynamic(response, entityList, objList, fileName, title, sheetName);
        }
    }
    public static <T> void exportExcel(HttpServletResponse response, String fileName, String title, String sheetName,
                                       List<T> dataList, List<ProjectDeptDetailsChildVO> projectDeptDetailsChildVOS, String headerName, String headerValue) throws Exception {
        if (CollectionUtils.isNotEmpty(dataList)) {
            ProjectDeptDetailsChildVO dataInstance = projectDeptDetailsChildVOS.get(0);
            List<ExcelExportEntity> entityList = buildExcelExportEntityList(dataInstance, headerName, "");
            List<Object> objList = convertDataListToObjList(dataList, headerName,headerValue);
            downloadExcelEntityDynamic(response, entityList, objList, fileName, title, sheetName);
        }
    }
    public static <T> void exportExcel(HttpServletResponse response, String fileName, String title, String sheetName,
                                       List<T> dataList, String headerName, String headerValue, String ignoreCol) throws Exception {
        if (CollectionUtils.isNotEmpty(dataList)) {
@@ -82,7 +92,7 @@
     * @return Excel导出实体列表
     * @throws IllegalAccessException 如果无法访问字段
     */
    private static <T> List<ExcelExportEntity> buildExcelExportEntityList(T t, String headerName, String ignoreCol) throws IllegalAccessException {
    public static <T> List<ExcelExportEntity> buildExcelExportEntityList(T t, String headerName, String ignoreCol) throws IllegalAccessException {
        List<ExcelExportEntity> entityList = new ArrayList<>();
        Field[] fields = t.getClass().getDeclaredFields();
        int index = 0;