| | |
| | | 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; |
| | |
| | | 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 { |
| | |
| | | * @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; |