org.jeecgframework.poi.excel.entity.params.ExcelExportEntity Java Examples

The following examples show how to use org.jeecgframework.poi.excel.entity.params.ExcelExportEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExcelEntityParse.java    From autopoi with Apache License 2.0 6 votes vote down vote up
/**
 * 对导出序列进行排序和塞选
 * 
 * @param excelParams
 * @param titlemap
 * @return
 */
private void sortAndFilterExportField(List<ExcelExportEntity> excelParams, Map<String, Integer> titlemap) {
	for (int i = excelParams.size() - 1; i >= 0; i--) {
		if (excelParams.get(i).getList() != null && excelParams.get(i).getList().size() > 0) {
			sortAndFilterExportField(excelParams.get(i).getList(), titlemap);
			if (excelParams.get(i).getList().size() == 0) {
				excelParams.remove(i);
			} else {
				excelParams.get(i).setOrderNum(i);
			}
		} else {
			if (titlemap.containsKey(excelParams.get(i).getName())) {
				excelParams.get(i).setOrderNum(i);
			} else {
				excelParams.remove(i);
			}
		}
	}
	sortAllParams(excelParams);
}
 
Example #2
Source File: ExcelExportBase.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
private Map<Integer, int[]> getMergeDataMap(List<ExcelExportEntity> excelParams) {
	Map<Integer, int[]> mergeMap = new HashMap<Integer, int[]>();
	// 设置参数顺序,为之后合并单元格做准备
	int i = 0;
	for (ExcelExportEntity entity : excelParams) {
		if (entity.isMergeVertical()) {
			mergeMap.put(i, entity.getMergeRely());
		}
		if (entity.getList() != null) {
			for (ExcelExportEntity inner : entity.getList()) {
				if (inner.isMergeVertical()) {
					mergeMap.put(i, inner.getMergeRely());
				}
				i++;
			}
		} else {
			i++;
		}
	}
	return mergeMap;
}
 
Example #3
Source File: ExcelExportBase.java    From autopoi with Apache License 2.0 6 votes vote down vote up
private Map<Integer, int[]> getMergeDataMap(List<ExcelExportEntity> excelParams) {
	Map<Integer, int[]> mergeMap = new HashMap<Integer, int[]>();
	// 设置参数顺序,为之后合并单元格做准备
	int i = 0;
	for (ExcelExportEntity entity : excelParams) {
		if (entity.isMergeVertical()) {
			mergeMap.put(i, entity.getMergeRely());
		}
		if (entity.getList() != null) {
			for (ExcelExportEntity inner : entity.getList()) {
				if (inner.isMergeVertical()) {
					mergeMap.put(i, inner.getMergeRely());
				}
				i++;
			}
		} else {
			i++;
		}
	}
	return mergeMap;
}
 
Example #4
Source File: ExcelEntityParse.java    From easypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建List之后的各个Cells
 * 
 * @param styles
 */
public void createListCells(int index, int cellNum, Object obj,
                            List<ExcelExportEntity> excelParams, XWPFTable table)
                                                                                 throws Exception {
    ExcelExportEntity entity;
    XWPFTableRow row;
    if (table.getRow(index) == null) {
        row = table.createRow();
        row.setHeight(getRowHeight(excelParams));
    } else {
        row = table.getRow(index);
    }
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
        entity = excelParams.get(k);
        Object value = getCellValue(entity, obj);
        if (entity.getType() == 1) {
            setCellValue(row, value, cellNum++);
        }
    }
}
 
Example #5
Source File: ExportBase.java    From easypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建导出实体对象
 * 
 * @param field
 * @param targetId
 * @param pojoClass
 * @param getMethods
 * @return
 * @throws Exception
 */
private ExcelExportEntity createExcelExportEntity(Field field, String targetId,
                                                  Class<?> pojoClass, List<Method> getMethods)
                                                                                              throws Exception {
    Excel excel = field.getAnnotation(Excel.class);
    ExcelExportEntity excelEntity = new ExcelExportEntity();
    excelEntity.setType(excel.type());
    getExcelField(targetId, field, excelEntity, excel, pojoClass);
    if (getMethods != null) {
        List<Method> newMethods = new ArrayList<Method>();
        newMethods.addAll(getMethods);
        newMethods.add(excelEntity.getMethod());
        excelEntity.setMethods(newMethods);
    }
    return excelEntity;
}
 
Example #6
Source File: ExportBase.java    From easypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 获取填如这个cell的值,提供一些附加功能
 * 
 * @param entity
 * @param obj
 * @return
 * @throws Exception
 */
public Object getCellValue(ExcelExportEntity entity, Object obj) throws Exception {
    Object value;
    if (obj instanceof Map) {
        value = ((Map<?, ?>) obj).get(entity.getKey());
    } else {
        value = entity.getMethods() != null ? getFieldBySomeMethod(entity.getMethods(), obj)
            : entity.getMethod().invoke(obj, new Object[] {});
    }
    if (StringUtils.isNotEmpty(entity.getFormat())) {
        value = formatValue(value, entity);
    }
    if (entity.getReplace() != null && entity.getReplace().length > 0) {
        value = replaceValue(entity.getReplace(), String.valueOf(value));
    }
    if (needHanlderList != null && needHanlderList.contains(entity.getName())) {
        value = dataHanlder.exportHandler(obj, entity.getName(), value);
    }
    if (StringUtils.isNotEmpty(entity.getSuffix()) && value != null) {
        value = value + entity.getSuffix();
    }
    return value == null ? "" : value.toString();
}
 
Example #7
Source File: ExcelExportBase.java    From autopoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建List之后的各个Cells
 * 
 * @param styles
 */
public void createListCells(Drawing patriarch, int index, int cellNum, Object obj, List<ExcelExportEntity> excelParams, Sheet sheet, Workbook workbook) throws Exception {
	ExcelExportEntity entity;
	Row row;
	if (sheet.getRow(index) == null) {
		row = sheet.createRow(index);
		row.setHeight(getRowHeight(excelParams));
	} else {
		row = sheet.getRow(index);
	}
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		Object value = getCellValue(entity, obj);
		//update-begin--Author:xuelin  Date:20171018 for:TASK #2372 【excel】easypoi 导出类型,type增加数字类型--------------------
		if (entity.getType() == 1) {
			createStringCell(row, cellNum++, value == null ? "" : value.toString(), row.getRowNum() % 2 == 0 ? getStyles(false, entity) : getStyles(true, entity), entity);
		} else if (entity.getType() == 4){
			createNumericCell(row, cellNum++, value == null ? "" : value.toString(), index % 2 == 0 ? getStyles(false, entity) : getStyles(true, entity), entity);
		}  else{
			createImageCell(patriarch, entity, row, cellNum++, value == null ? "" : value.toString(), obj);
		}
		//update-end--Author:xuelin  Date:20171018 for:TASK #2372 【excel】easypoi 导出类型,type增加数字类型--------------------
	}
}
 
Example #8
Source File: ExportBase.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 获取填如这个cell的值,提供一些附加功能
 * 
 * @param entity
 * @param obj
 * @return
 * @throws Exception
 */
public Object getCellValue(ExcelExportEntity entity, Object obj) throws Exception {
	Object value;
	if (obj instanceof Map) {
		value = ((Map<?, ?>) obj).get(entity.getKey());
	} else {
		value = entity.getMethods() != null ? getFieldBySomeMethod(entity.getMethods(), obj) : entity.getMethod().invoke(obj, new Object[] {});
	}
	if (StringUtils.isNotEmpty(entity.getFormat())) {
		value = formatValue(value, entity);
	}
	if (entity.getReplace() != null && entity.getReplace().length > 0) {
		value = replaceValue(entity.getReplace(), String.valueOf(value));
	}
	if (needHanlderList != null && needHanlderList.contains(entity.getName())) {
		value = dataHanlder.exportHandler(obj, entity.getName(), value);
	}
	if (StringUtils.isNotEmpty(entity.getSuffix()) && value != null) {
		value = value + entity.getSuffix();
	}
	return value == null ? "" : value.toString();
}
 
Example #9
Source File: ExportBase.java    From easypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 注解到导出对象的转换
 * 
 * @param targetId
 * @param field
 * @param excelEntity
 * @param excel
 * @param pojoClass
 * @throws Exception
 */
private void getExcelField(String targetId, Field field, ExcelExportEntity excelEntity,
                           Excel excel, Class<?> pojoClass) throws Exception {
    excelEntity.setName(getExcelName(excel.name(), targetId));
    excelEntity.setWidth(excel.width());
    excelEntity.setHeight(excel.height());
    excelEntity.setNeedMerge(excel.needMerge());
    excelEntity.setMergeVertical(excel.mergeVertical());
    excelEntity.setMergeRely(excel.mergeRely());
    excelEntity.setReplace(excel.replace());
    excelEntity.setOrderNum(getCellOrder(excel.orderNum(), targetId));
    excelEntity.setWrap(excel.isWrap());
    excelEntity.setExportImageType(excel.imageType());
    excelEntity.setSuffix(excel.suffix());
    excelEntity.setDatabaseFormat(excel.databaseFormat());
    excelEntity.setFormat(StringUtils.isNotEmpty(excel.exportFormat()) ? excel.exportFormat()
        : excel.format());
    excelEntity.setStatistics(excel.isStatistics());
    String fieldname = field.getName();
    excelEntity.setMethod(PoiPublicUtil.getMethod(fieldname, pojoClass));
}
 
Example #10
Source File: JeecgMapExcelView.java    From autopoi with Apache License 2.0 6 votes vote down vote up
@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
	String codedFileName = "临时文件";
	Workbook workbook = ExcelExportUtil.exportExcel((ExportParams) model.get(MapExcelConstants.PARAMS), (List<ExcelExportEntity>) model.get(MapExcelConstants.ENTITY_LIST), (Collection<? extends Map<?, ?>>) model.get(MapExcelConstants.MAP_LIST));
	if (model.containsKey(MapExcelConstants.FILE_NAME)) {
		codedFileName = (String) model.get(MapExcelConstants.FILE_NAME);
	}
	if (workbook instanceof HSSFWorkbook) {
		codedFileName += HSSF;
	} else {
		codedFileName += XSSF;
	}
	if (isIE(request)) {
		codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8");
	} else {
		codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
	}
	response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
	ServletOutputStream out = response.getOutputStream();
	workbook.write(out);
	out.flush();
}
 
Example #11
Source File: ExcelExportBase.java    From easypoi with Apache License 2.0 6 votes vote down vote up
private Map<Integer, int[]> getMergeDataMap(List<ExcelExportEntity> excelParams) {
    Map<Integer, int[]> mergeMap = new HashMap<Integer, int[]>();
    // 设置参数顺序,为之后合并单元格做准备
    int i = 0;
    for (ExcelExportEntity entity : excelParams) {
        if (entity.isMergeVertical()) {
            mergeMap.put(i, entity.getMergeRely());
        }
        if (entity.getList() != null) {
            for (ExcelExportEntity inner : entity.getList()) {
                if (inner.isMergeVertical()) {
                    mergeMap.put(i, inner.getMergeRely());
                }
                i++;
            }
        } else {
            i++;
        }
    }
    return mergeMap;
}
 
Example #12
Source File: JeecgMapExcelView.java    From easypoi with Apache License 2.0 6 votes vote down vote up
@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
                                       HttpServletResponse response) throws Exception {
    String codedFileName = "临时文件";
    Workbook workbook = ExcelExportUtil.exportExcel(
        (ExportParams) model.get(MapExcelConstants.PARAMS),
        (List<ExcelExportEntity>) model.get(MapExcelConstants.ENTITY_LIST),
        (Collection<? extends Map<?, ?>>) model.get(MapExcelConstants.MAP_LIST));
    if (model.containsKey(MapExcelConstants.FILE_NAME)) {
        codedFileName = (String) model.get(MapExcelConstants.FILE_NAME);
    }
    if (workbook instanceof HSSFWorkbook) {
        codedFileName += HSSF;
    } else {
        codedFileName += XSSF;
    }
    if (isIE(request)) {
        codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8");
    } else {
        codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
    }
    response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
    ServletOutputStream out = response.getOutputStream();
    workbook.write(out);
    out.flush();
}
 
Example #13
Source File: ExcelExportBase.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建List之后的各个Cells
 * 
 * @param styles
 */
public void createListCells(Drawing patriarch, int index, int cellNum, Object obj, List<ExcelExportEntity> excelParams, Sheet sheet, Workbook workbook) throws Exception {
	ExcelExportEntity entity;
	Row row;
	if (sheet.getRow(index) == null) {
		row = sheet.createRow(index);
		row.setHeight(getRowHeight(excelParams));
	} else {
		row = sheet.getRow(index);
	}
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		Object value = getCellValue(entity, obj);
		if (entity.getType() == 1) {
			createStringCell(row, cellNum++, value == null ? "" : value.toString(), row.getRowNum() % 2 == 0 ? getStyles(false, entity) : getStyles(true, entity), entity);
		} else if (entity.getType() == 4){
			createNumericCell(row, cellNum++, value == null ? "" : value.toString(), index % 2 == 0 ? getStyles(false, entity) : getStyles(true, entity), entity);
		}  else{
			createImageCell(patriarch, entity, row, cellNum++, value == null ? "" : value.toString(), obj);
		}
	}
}
 
Example #14
Source File: ExcelExportBase.java    From easypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建List之后的各个Cells
 * 
 * @param styles
 */
public void createListCells(Drawing patriarch, int index, int cellNum, Object obj,
                            List<ExcelExportEntity> excelParams, Sheet sheet, Workbook workbook)
                                                                                                throws Exception {
    ExcelExportEntity entity;
    Row row;
    if (sheet.getRow(index) == null) {
        row = sheet.createRow(index);
        row.setHeight(getRowHeight(excelParams));
    } else {
        row = sheet.getRow(index);
    }
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
        entity = excelParams.get(k);
        Object value = getCellValue(entity, obj);
        if (entity.getType() == 1) {
            createStringCell(row, cellNum++, value == null ? "" : value.toString(),
                row.getRowNum() % 2 == 0 ? getStyles(false, entity) : getStyles(true, entity),
                entity);
        } else {
            createImageCell(patriarch, entity, row, cellNum++,
                value == null ? "" : value.toString(), obj);
        }
    }
}
 
Example #15
Source File: ExcelEntityParse.java    From autopoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建List之后的各个Cells
 * 
 * @param styles
 */
public void createListCells(int index, int cellNum, Object obj, List<ExcelExportEntity> excelParams, XWPFTable table) throws Exception {
	ExcelExportEntity entity;
	XWPFTableRow row;
	if (table.getRow(index) == null) {
		row = table.createRow();
		row.setHeight(getRowHeight(excelParams));
	} else {
		row = table.getRow(index);
	}
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		Object value = getCellValue(entity, obj);
		if (entity.getType() == 1) {
			setCellValue(row, value, cellNum++);
		}
	}
}
 
Example #16
Source File: ExcelEntityParse.java    From easypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 对导出序列进行排序和塞选
 * 
 * @param excelParams
 * @param titlemap
 * @return
 */
private void sortAndFilterExportField(List<ExcelExportEntity> excelParams,
                                      Map<String, Integer> titlemap) {
    for (int i = excelParams.size() - 1; i >= 0; i--) {
        if (excelParams.get(i).getList() != null && excelParams.get(i).getList().size() > 0) {
            sortAndFilterExportField(excelParams.get(i).getList(), titlemap);
            if (excelParams.get(i).getList().size() == 0) {
                excelParams.remove(i);
            } else {
                excelParams.get(i).setOrderNum(i);
            }
        } else {
            if (titlemap.containsKey(excelParams.get(i).getName())) {
                excelParams.get(i).setOrderNum(i);
            } else {
                excelParams.remove(i);
            }
        }
    }
    sortAllParams(excelParams);
}
 
Example #17
Source File: ExcelExportOfTemplateUtil.java    From easypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 获取单个对象的高度,主要是处理一堆多的情况
 * 
 * @param styles
 * @param rowHeight
 * @throws Exception
 */
public int getOneObjectSize(Object t, List<ExcelExportEntity> excelParams) throws Exception {
    ExcelExportEntity entity;
    int maxHeight = 1;
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
        entity = excelParams.get(k);
        if (entity.getList() != null) {
            Collection<?> list = (Collection<?>) entity.getMethod().invoke(t, new Object[] {});
            if (list != null && list.size() > maxHeight) {
                maxHeight = list.size();
            }
        }
    }
    return maxHeight;

}
 
Example #18
Source File: ExcelTempletController.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
 * 把基础数据转换成Excel导出的数据
 *
 * @param lists
 * @return
 */
private List<ExcelExportEntity> convertToExportEntity(List<CgFormFieldEntity> lists) {
	// 对字段列按顺序排序
	Collections.sort(lists, new FieldNumComparator());
	List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();
	for (int i = 0; i < lists.size(); i++) {
		if (lists.get(i).getIsShow().equals("Y")) {
			ExcelExportEntity entity = new ExcelExportEntity(lists.get(i).getContent(), lists.get(i).getFieldName());
			int columnWidth = lists.get(i).getLength() == 0 ? 12 : lists.get(i).getLength() > 30 ? 30 : lists.get(i).getLength();
			if (lists.get(i).getShowType().equals("date")) {
				entity.setFormat("yyyy-MM-dd");
			} else if (lists.get(i).getShowType().equals("datetime")) {
				entity.setFormat("yyyy-MM-dd HH:mm:ss");
			}
			entity.setWidth(columnWidth);
			entityList.add(entity);
		}
	}
	return entityList;
}
 
Example #19
Source File: ExcelExportOfTemplateUtil.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 对导出序列进行排序和塞选
 * 
 * @param excelParams
 * @param titlemap
 * @return
 */
private void sortAndFilterExportField(List<ExcelExportEntity> excelParams, Map<String, Integer> titlemap) {
	for (int i = excelParams.size() - 1; i >= 0; i--) {
		if (excelParams.get(i).getList() != null && excelParams.get(i).getList().size() > 0) {
			sortAndFilterExportField(excelParams.get(i).getList(), titlemap);
			if (excelParams.get(i).getList().size() == 0) {
				excelParams.remove(i);
			} else {
				excelParams.get(i).setOrderNum(i);
			}
		} else {
			if (titlemap.containsKey(excelParams.get(i).getName())) {
				excelParams.get(i).setOrderNum(i);
			} else {
				excelParams.remove(i);
			}
		}
	}
	sortAllParams(excelParams);
}
 
Example #20
Source File: ExcelEntityParse.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建List之后的各个Cells
 * 
 * @param styles
 */
public void createListCells(int index, int cellNum, Object obj, List<ExcelExportEntity> excelParams, XWPFTable table) throws Exception {
	ExcelExportEntity entity;
	XWPFTableRow row;
	if (table.getRow(index) == null) {
		row = table.createRow();
		row.setHeight(getRowHeight(excelParams));
	} else {
		row = table.getRow(index);
	}
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		Object value = getCellValue(entity, obj);
		if (entity.getType() == 1) {
			setCellValue(row, value, cellNum++);
		}
	}
}
 
Example #21
Source File: ExcelEntityParse.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 对导出序列进行排序和塞选
 * 
 * @param excelParams
 * @param titlemap
 * @return
 */
private void sortAndFilterExportField(List<ExcelExportEntity> excelParams, Map<String, Integer> titlemap) {
	for (int i = excelParams.size() - 1; i >= 0; i--) {
		if (excelParams.get(i).getList() != null && excelParams.get(i).getList().size() > 0) {
			sortAndFilterExportField(excelParams.get(i).getList(), titlemap);
			if (excelParams.get(i).getList().size() == 0) {
				excelParams.remove(i);
			} else {
				excelParams.get(i).setOrderNum(i);
			}
		} else {
			if (titlemap.containsKey(excelParams.get(i).getName())) {
				excelParams.get(i).setOrderNum(i);
			} else {
				excelParams.remove(i);
			}
		}
	}
	sortAllParams(excelParams);
}
 
Example #22
Source File: JeecgMapExcelView.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
	String codedFileName = "临时文件";
	Workbook workbook = ExcelExportUtil.exportExcel((ExportParams) model.get(MapExcelConstants.PARAMS), (List<ExcelExportEntity>) model.get(MapExcelConstants.ENTITY_LIST), (Collection<? extends Map<?, ?>>) model.get(MapExcelConstants.MAP_LIST));
	if (model.containsKey(MapExcelConstants.FILE_NAME)) {
		codedFileName = (String) model.get(MapExcelConstants.FILE_NAME);
	}
	if (workbook instanceof HSSFWorkbook) {
		codedFileName += HSSF;
	} else {
		codedFileName += XSSF;
	}
	if (isIE(request)) {
		codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8");
	} else {
		codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
	}
	response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
	ServletOutputStream out = response.getOutputStream();
	workbook.write(out);
	out.flush();
}
 
Example #23
Source File: ExcelTempletController.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
 * 把从表数据加到主表中
 *
 * @param subTable
 * @param configs
 * @param result
 * @param entityList
 */
private void addAllSubTableDate(String subTable, Map<String, Object> configs, List<Map<String, Object>> result, List<ExcelExportEntity> entityList) {
	String jversion = cgFormFieldService.getCgFormVersionByTableName(subTable);
	Map<String, Object> subConfigs = configService.queryConfigs(subTable, jversion);
	ExcelExportEntity tableEntity = new ExcelExportEntity(subConfigs.get(CgAutoListConstant.CONFIG_NAME).toString(), subTable);
	List<CgFormFieldEntity> beans = (List<CgFormFieldEntity>) subConfigs.get(CgAutoListConstant.FILEDS);
	tableEntity.setList(convertToExportEntity(beans));
	entityList.add(tableEntity);
	// 对字段列按顺序排序
	for (int i = 0; i < result.size(); i++) {
		List<Map<String, Object>> subResult = cgFormFieldService.getSubTableData(configs.get(CgAutoListConstant.CONFIG_ID).toString(), subTable, result.get(i).get("id"));
		handlePageDic(beans, subResult);
		dealDic(subResult, beans);
		result.get(i).put(subTable,subResult);
	}
}
 
Example #24
Source File: ExportBase.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 获取集合的值
 * 
 * @param entity
 * @param obj
 * @return
 * @throws Exception
 */
public Collection<?> getListCellValue(ExcelExportEntity entity, Object obj) throws Exception {
	Object value;
	if (obj instanceof Map) {
		value = ((Map<?, ?>) obj).get(entity.getKey());
	} else {
		value = (Collection<?>) entity.getMethod().invoke(obj, new Object[] {});
	}
	return (Collection<?>) value;
}
 
Example #25
Source File: ExportBase.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 对字段根据用户设置排序
 */
public void sortAllParams(List<ExcelExportEntity> excelParams) {
	Collections.sort(excelParams);
	for (ExcelExportEntity entity : excelParams) {
		if (entity.getList() != null) {
			Collections.sort(entity.getList());
		}
	}
}
 
Example #26
Source File: ExportBase.java    From easypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 对字段根据用户设置排序
 */
public void sortAllParams(List<ExcelExportEntity> excelParams) {
    Collections.sort(excelParams);
    for (ExcelExportEntity entity : excelParams) {
        if (entity.getList() != null) {
            Collections.sort(entity.getList());
        }
    }
}
 
Example #27
Source File: ExcelExportServer.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 判断表头是只有一行还是两行
 * 
 * @param excelParams
 * @return
 */
private int getRowNums(List<ExcelExportEntity> excelParams) {
	for (int i = 0; i < excelParams.size(); i++) {
		if (excelParams.get(i).getList() != null && StringUtils.isNotBlank(excelParams.get(i).getName())) {
			return 2;
		}
	}
	return 1;
}
 
Example #28
Source File: ExcelExportOfTemplateUtil.java    From easypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 下移数据
 * @param its
 * @param excelParams
 * @return
 */
private int getShiftRows(Collection<?> dataSet, List<ExcelExportEntity> excelParams)
                                                                                    throws Exception {
    int size = 0;
    Iterator<?> its = dataSet.iterator();
    while (its.hasNext()) {
        Object t = its.next();
        size += getOneObjectSize(t, excelParams);
    }
    return size;
}
 
Example #29
Source File: ExcelExportServer.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
private int createHeaderAndTitle(ExportParams entity, Sheet sheet, Workbook workbook, List<ExcelExportEntity> excelParams) {
	int rows = 0, feildWidth = getFieldWidth(excelParams);
	if (entity.getTitle() != null) {
		rows += createHeaderRow(entity, sheet, workbook, feildWidth);
	}
	rows += createTitleRow(entity, sheet, workbook, rows, excelParams);
	sheet.createFreezePane(0, rows, 0, rows);
	return rows;
}
 
Example #30
Source File: ExportBase.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 创建导出实体对象
 * 
 * @param field
 * @param targetId
 * @param pojoClass
 * @param getMethods
 * @return
 * @throws Exception
 */
private ExcelExportEntity createExcelExportEntity(Field field, String targetId, Class<?> pojoClass, List<Method> getMethods) throws Exception {
	Excel excel = field.getAnnotation(Excel.class);
	ExcelExportEntity excelEntity = new ExcelExportEntity();
	excelEntity.setType(excel.type());
	getExcelField(targetId, field, excelEntity, excel, pojoClass);
	if (getMethods != null) {
		List<Method> newMethods = new ArrayList<Method>();
		newMethods.addAll(getMethods);
		newMethods.add(excelEntity.getMethod());
		excelEntity.setMethods(newMethods);
	}
	return excelEntity;
}