Java Code Examples for org.jeecgframework.poi.excel.entity.params.ExcelExportEntity#getType()

The following examples show how to use org.jeecgframework.poi.excel.entity.params.ExcelExportEntity#getType() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
Source File: ExcelEntityParse.java    From autopoi with Apache License 2.0 5 votes vote down vote up
private int createCells(int index, Object t, List<ExcelExportEntity> excelParams, XWPFTable table, short rowHeight) throws Exception {
	ExcelExportEntity entity;
	XWPFTableRow row = table.createRow();
	row.setHeight(rowHeight);
	int maxHeight = 1, cellNum = 0;
	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[] {});
			int listC = 0;
			for (Object obj : list) {
				createListCells(index + listC, cellNum, obj, entity.getList(), table);
				listC++;
			}
			cellNum += entity.getList().size();
			if (list != null && list.size() > maxHeight) {
				maxHeight = list.size();
			}
		} else {
			Object value = getCellValue(entity, t);
			if (entity.getType() == 1) {
				setCellValue(row, value, cellNum++);
			}
		}
	}
	// 合并需要合并的单元格
	cellNum = 0;
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		if (entity.getList() != null) {
			cellNum += entity.getList().size();
		} else if (entity.isNeedMerge()) {
			table.setCellMargins(index, index + maxHeight - 1, cellNum, cellNum);
			cellNum++;
		}
	}
	return maxHeight;
}
 
Example 8
Source File: ExcelEntityParse.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
private int createCells(int index, Object t, List<ExcelExportEntity> excelParams, XWPFTable table, short rowHeight) throws Exception {
	ExcelExportEntity entity;
	XWPFTableRow row = table.createRow();
	row.setHeight(rowHeight);
	int maxHeight = 1, cellNum = 0;
	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[] {});
			int listC = 0;
			for (Object obj : list) {
				createListCells(index + listC, cellNum, obj, entity.getList(), table);
				listC++;
			}
			cellNum += entity.getList().size();
			if (list != null && list.size() > maxHeight) {
				maxHeight = list.size();
			}
		} else {
			Object value = getCellValue(entity, t);
			if (entity.getType() == 1) {
				setCellValue(row, value, cellNum++);
			}
		}
	}
	// 合并需要合并的单元格
	cellNum = 0;
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		if (entity.getList() != null) {
			cellNum += entity.getList().size();
		} else if (entity.isNeedMerge()) {
			table.setCellMargins(index, index + maxHeight - 1, cellNum, cellNum);
			cellNum++;
		}
	}
	return maxHeight;
}
 
Example 9
Source File: ExcelEntityParse.java    From easypoi with Apache License 2.0 5 votes vote down vote up
private int createCells(int index, Object t, List<ExcelExportEntity> excelParams,
                        XWPFTable table, short rowHeight) throws Exception {
    ExcelExportEntity entity;
    XWPFTableRow row = table.createRow();
    row.setHeight(rowHeight);
    int maxHeight = 1, cellNum = 0;
    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[] {});
            int listC = 0;
            for (Object obj : list) {
                createListCells(index + listC, cellNum, obj, entity.getList(), table);
                listC++;
            }
            cellNum += entity.getList().size();
            if (list != null && list.size() > maxHeight) {
                maxHeight = list.size();
            }
        } else {
            Object value = getCellValue(entity, t);
            if (entity.getType() == 1) {
                setCellValue(row, value, cellNum++);
            }
        }
    }
    // 合并需要合并的单元格
    cellNum = 0;
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
        entity = excelParams.get(k);
        if (entity.getList() != null) {
            cellNum += entity.getList().size();
        } else if (entity.isNeedMerge()) {
            table.setCellMargins(index, index + maxHeight - 1, cellNum, cellNum);
            cellNum++;
        }
    }
    return maxHeight;
}
 
Example 10
Source File: ExcelExportBase.java    From autopoi with Apache License 2.0 4 votes vote down vote up
/**
 * 创建 最主要的 Cells
 * 
 * @param styles
 * @param rowHeight
 * @throws Exception
 */
public int createCells(Drawing patriarch, int index, Object t, List<ExcelExportEntity> excelParams, Sheet sheet, Workbook workbook, short rowHeight) throws Exception {
	ExcelExportEntity entity;
	Row row = sheet.createRow(index);
	row.setHeight(rowHeight);
	int maxHeight = 1, cellNum = 0;
	int indexKey = createIndexCell(row, index, excelParams.get(0));
	cellNum += indexKey;
	for (int k = indexKey, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		//update-begin-author:taoyan date:20200319 for:建议autoPoi升级,优化数据返回List Map格式下的复合表头导出excel的体验 #873
		if(entity.isSubColumn()){
			continue;
		}
		if(entity.isMergeColumn()){
			Map<String,Object> subColumnMap = new HashMap<>();
			List<String> mapKeys = entity.getSubColumnList();
			for (String subKey : mapKeys) {
				Object subKeyValue = null;
				if (t instanceof Map) {
					subKeyValue = ((Map<?, ?>) t).get(subKey);
				}else{
					subKeyValue = PoiPublicUtil.getParamsValue(subKey,t);
				}
				subColumnMap.put(subKey,subKeyValue);
			}
			createListCells(patriarch, index, cellNum, subColumnMap, entity.getList(), sheet, workbook);
			cellNum += entity.getSubColumnList().size();
		//update-end-author:taoyan date:20200319 for:建议autoPoi升级,优化数据返回List Map格式下的复合表头导出excel的体验 #873
		} else if (entity.getList() != null) {
			Collection<?> list = getListCellValue(entity, t);
			int listC = 0;
			for (Object obj : list) {
				createListCells(patriarch, index + listC, cellNum, obj, entity.getList(), sheet, workbook);
				listC++;
			}
			cellNum += entity.getList().size();
			if (list != null && list.size() > maxHeight) {
				maxHeight = list.size();
			}
		} else {
			Object value = getCellValue(entity, t);
			//update-begin--Author:xuelin  Date:20171018 for:TASK #2372 【excel】easypoi 导出类型,type增加数字类型--------------------
			if (entity.getType() == 1) {
				createStringCell(row, cellNum++, value == null ? "" : value.toString(), index % 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(), t);
			}
			//update-end--Author:xuelin  Date:20171018 for:TASK #2372 【excel】easypoi 导出类型,type增加数字类型--------------------
		}
	}
	// 合并需要合并的单元格
	cellNum = 0;
	for (int k = indexKey, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		if (entity.getList() != null) {
			cellNum += entity.getList().size();
		} else if (entity.isNeedMerge()) {
			for (int i = index + 1; i < index + maxHeight; i++) {
				sheet.getRow(i).createCell(cellNum);
				sheet.getRow(i).getCell(cellNum).setCellStyle(getStyles(false, entity));
			}
			sheet.addMergedRegion(new CellRangeAddress(index, index + maxHeight - 1, cellNum, cellNum));
			cellNum++;
		}
	}
	return maxHeight;

}
 
Example 11
Source File: ExcelExportBase.java    From jeasypoi with Apache License 2.0 4 votes vote down vote up
/**
 * 创建 最主要的 Cells
 * 
 * @param styles
 * @param rowHeight
 * @throws Exception
 */
public int createCells(Drawing patriarch, int index, Object t, List<ExcelExportEntity> excelParams, Sheet sheet, Workbook workbook, short rowHeight) throws Exception {
	ExcelExportEntity entity;
	Row row = sheet.createRow(index);
	row.setHeight(rowHeight);
	int maxHeight = 1, cellNum = 0;
	int indexKey = createIndexCell(row, index, excelParams.get(0));
	cellNum += indexKey;
	for (int k = indexKey, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		if (entity.getList() != null) {
			Collection<?> list = getListCellValue(entity, t);
			int listC = 0;
			for (Object obj : list) {
				createListCells(patriarch, index + listC, cellNum, obj, entity.getList(), sheet, workbook);
				listC++;
			}
			cellNum += entity.getList().size();
			if (list != null && list.size() > maxHeight) {
				maxHeight = list.size();
			}
		} else {
			Object value = getCellValue(entity, t);
			if (entity.getType() == 1) {
				createStringCell(row, cellNum++, value == null ? "" : value.toString(), index % 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(), t);
			}
		}
	}
	// 合并需要合并的单元格
	cellNum = 0;
	for (int k = indexKey, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		if (entity.getList() != null) {
			cellNum += entity.getList().size();
		} else if (entity.isNeedMerge()) {
			for (int i = index + 1; i < index + maxHeight; i++) {
				sheet.getRow(i).createCell(cellNum);
				sheet.getRow(i).getCell(cellNum).setCellStyle(getStyles(false, entity));
			}
			sheet.addMergedRegion(new CellRangeAddress(index, index + maxHeight - 1, cellNum, cellNum));
			cellNum++;
		}
	}
	return maxHeight;

}
 
Example 12
Source File: ExcelExportBase.java    From easypoi with Apache License 2.0 4 votes vote down vote up
/**
 * 创建 最主要的 Cells
 * 
 * @param styles
 * @param rowHeight
 * @throws Exception
 */
public int createCells(Drawing patriarch, int index, Object t,
                       List<ExcelExportEntity> excelParams, Sheet sheet, Workbook workbook,
                       short rowHeight) throws Exception {
    ExcelExportEntity entity;
    Row row = sheet.createRow(index);
    row.setHeight(rowHeight);
    int maxHeight = 1, cellNum = 0;
    int indexKey = createIndexCell(row, index, excelParams.get(0));
    cellNum += indexKey;
    for (int k = indexKey, paramSize = excelParams.size(); k < paramSize; k++) {
        entity = excelParams.get(k);
        if (entity.getList() != null) {
            Collection<?> list = getListCellValue(entity, t);
            int listC = 0;
            for (Object obj : list) {
                createListCells(patriarch, index + listC, cellNum, obj, entity.getList(),
                    sheet, workbook);
                listC++;
            }
            cellNum += entity.getList().size();
            if (list != null && list.size() > maxHeight) {
                maxHeight = list.size();
            }
        } else {
            Object value = getCellValue(entity, t);
            if (entity.getType() == 1) {
                createStringCell(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(), t);
            }
        }
    }
    // 合并需要合并的单元格
    cellNum = 0;
    for (int k = indexKey, paramSize = excelParams.size(); k < paramSize; k++) {
        entity = excelParams.get(k);
        if (entity.getList() != null) {
            cellNum += entity.getList().size();
        } else if (entity.isNeedMerge()) {
            for (int i = index + 1; i < index + maxHeight; i++) {
                sheet.getRow(i).createCell(cellNum);
                sheet.getRow(i).getCell(cellNum).setCellStyle(getStyles(false, entity));
            }
            sheet.addMergedRegion(new CellRangeAddress(index, index + maxHeight - 1, cellNum,
                cellNum));
            cellNum++;
        }
    }
    return maxHeight;

}