From 02bb94e413f6950b9786c5ee86c0937bc20f8ae8 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期六, 12 七月 2025 14:42:20 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-system/src/main/java/com/ruoyi/system/utils/ExcelPoiUtils.java | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/utils/ExcelPoiUtils.java b/ruoyi-system/src/main/java/com/ruoyi/system/utils/ExcelPoiUtils.java index 461e114..c8da239 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/utils/ExcelPoiUtils.java +++ b/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; -- Gitblit v1.7.1