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

The following examples show how to use org.jeecgframework.poi.excel.entity.params.ExcelTemplateParams. 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: ExcelExportOfTemplateUtil.java    From autopoi with Apache License 2.0 6 votes vote down vote up
private void setForEeachCellValue(boolean isCreate, Row row, int columnIndex, Object t, List<ExcelTemplateParams> columns, Map<String, Object> map) throws Exception {
	for (int i = 0, max = columnIndex + columns.size(); i < max; i++) {
		if (row.getCell(i) == null)
			row.createCell(i);
	}
	for (int i = 0, max = columns.size(); i < max; i++) {
		boolean isNumber = false;
		String tempStr = new String(columns.get(i).getName());
		if (isNumber(tempStr)) {
			isNumber = true;
			tempStr = tempStr.replace(NUMBER_SYMBOL, "");
		}
		map.put(teplateParams.getTempParams(), t);
		String val = eval(tempStr, map).toString();
		if (isNumber && StringUtils.isNotEmpty(val)) {
			row.getCell(i + columnIndex).setCellValue(Double.parseDouble(val));
			row.getCell(i + columnIndex).setCellType(Cell.CELL_TYPE_NUMERIC);
		} else {
			row.getCell(i + columnIndex).setCellValue(val);
		}
		row.getCell(i + columnIndex).setCellStyle(columns.get(i).getCellStyle());
		tempCreateCellSet.add(row.getRowNum() + "_" + (i + columnIndex));
	}

}
 
Example #2
Source File: ExcelExportOfTemplateUtil.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
private void setForEeachCellValue(boolean isCreate, Row row, int columnIndex, Object t, List<ExcelTemplateParams> columns, Map<String, Object> map) throws Exception {
	for (int i = 0, max = columnIndex + columns.size(); i < max; i++) {
		if (row.getCell(i) == null)
			row.createCell(i);
	}
	for (int i = 0, max = columns.size(); i < max; i++) {
		boolean isNumber = false;
		String tempStr = new String(columns.get(i).getName());
		if (isNumber(tempStr)) {
			isNumber = true;
			tempStr = tempStr.replace(NUMBER_SYMBOL, "");
		}
		map.put(teplateParams.getTempParams(), t);
		String val = eval(tempStr, map).toString();
		if (isNumber && StringUtils.isNotEmpty(val)) {
			row.getCell(i + columnIndex).setCellValue(Double.parseDouble(val));
			row.getCell(i + columnIndex).setCellType(Cell.CELL_TYPE_NUMERIC);
		} else {
			row.getCell(i + columnIndex).setCellValue(val);
		}
		row.getCell(i + columnIndex).setCellStyle(columns.get(i).getCellStyle());
		tempCreateCellSet.add(row.getRowNum() + "_" + (i + columnIndex));
	}

}
 
Example #3
Source File: ExcelExportOfTemplateUtil.java    From easypoi with Apache License 2.0 5 votes vote down vote up
private void setForEeachCellValue(boolean isCreate, Row row, int columnIndex, Object t,
                                  List<ExcelTemplateParams> columns, Map<String, Object> map)
                                                                                             throws Exception {
    for (int i = 0, max = columnIndex + columns.size(); i < max; i++) {
        if (row.getCell(i) == null)
            row.createCell(i);
    }
    for (int i = 0, max = columns.size(); i < max; i++) {
        boolean isNumber = false;
        String tempStr = new String(columns.get(i).getName());
        if (isNumber(tempStr)) {
            isNumber = true;
            tempStr = tempStr.replace(NUMBER_SYMBOL, "");
        }
        map.put(teplateParams.getTempParams(), t);
        String val = eval(tempStr, map).toString();
        if (isNumber && StringUtils.isNotEmpty(val)) {
            row.getCell(i + columnIndex).setCellValue(Double.parseDouble(val));
            row.getCell(i + columnIndex).setCellType(Cell.CELL_TYPE_NUMERIC);
        } else {
            row.getCell(i + columnIndex).setCellValue(val);
        }
        row.getCell(i + columnIndex).setCellStyle(columns.get(i).getCellStyle());
        tempCreateCellSet.add(row.getRowNum() + "_" + (i + columnIndex));
    }

}
 
Example #4
Source File: ExcelExportOfTemplateUtil.java    From autopoi with Apache License 2.0 4 votes vote down vote up
/**
 * 获取迭代的数据的值
 * 
 * @param cell
 * @param name
 * @return
 */
private List<ExcelTemplateParams> getAllDataColumns(Cell cell, String name) {
	List<ExcelTemplateParams> columns = new ArrayList<ExcelTemplateParams>();
	cell.setCellValue("");
	if (name.contains(END_STR)) {
		columns.add(new ExcelTemplateParams(name.replace(END_STR, EMPTY).trim(), cell.getCellStyle(), cell.getRow().getHeight()));
		return columns;
	}
	columns.add(new ExcelTemplateParams(name.trim(), cell.getCellStyle(), cell.getRow().getHeight()));
	int index = cell.getColumnIndex();
	Cell tempCell;
	while (true) {
		tempCell = cell.getRow().getCell(++index);
		if (tempCell == null) {
			break;
		}
		String cellStringString;
		try {// 允许为空,单表示已经完结了,因为可能被删除了
			cellStringString = tempCell.getStringCellValue();
			if (StringUtils.isBlank(cellStringString)) {
				break;
			}
		} catch (Exception e) {
			throw new ExcelExportException("for each 当中存在空字符串,请检查模板");
		}
		// 把读取过的cell 置为空
		tempCell.setCellValue("");
		if (cellStringString.contains(END_STR)) {
			columns.add(new ExcelTemplateParams(cellStringString.trim().replace(END_STR, ""), tempCell.getCellStyle(), tempCell.getRow().getHeight()));
			break;
		} else {
			if (cellStringString.trim().contains(teplateParams.getTempParams())) {
				columns.add(new ExcelTemplateParams(cellStringString.trim(), tempCell.getCellStyle(), tempCell.getRow().getHeight()));
			} else {
				// 最后一行被删除了
				break;
			}
		}

	}
	return columns;
}
 
Example #5
Source File: ExcelExportOfTemplateUtil.java    From jeasypoi with Apache License 2.0 4 votes vote down vote up
/**
 * 获取迭代的数据的值
 * 
 * @param cell
 * @param name
 * @return
 */
private List<ExcelTemplateParams> getAllDataColumns(Cell cell, String name) {
	List<ExcelTemplateParams> columns = new ArrayList<ExcelTemplateParams>();
	cell.setCellValue("");
	if (name.contains(END_STR)) {
		columns.add(new ExcelTemplateParams(name.replace(END_STR, EMPTY).trim(), cell.getCellStyle(), cell.getRow().getHeight()));
		return columns;
	}
	columns.add(new ExcelTemplateParams(name.trim(), cell.getCellStyle(), cell.getRow().getHeight()));
	int index = cell.getColumnIndex();
	Cell tempCell;
	while (true) {
		tempCell = cell.getRow().getCell(++index);
		if (tempCell == null) {
			break;
		}
		String cellStringString;
		try {// 允许为空,单表示已经完结了,因为可能被删除了
			cellStringString = tempCell.getStringCellValue();
			if (StringUtils.isBlank(cellStringString)) {
				break;
			}
		} catch (Exception e) {
			throw new ExcelExportException("for each 当中存在空字符串,请检查模板");
		}
		// 把读取过的cell 置为空
		tempCell.setCellValue("");
		if (cellStringString.contains(END_STR)) {
			columns.add(new ExcelTemplateParams(cellStringString.trim().replace(END_STR, ""), tempCell.getCellStyle(), tempCell.getRow().getHeight()));
			break;
		} else {
			if (cellStringString.trim().contains(teplateParams.getTempParams())) {
				columns.add(new ExcelTemplateParams(cellStringString.trim(), tempCell.getCellStyle(), tempCell.getRow().getHeight()));
			} else {
				// 最后一行被删除了
				break;
			}
		}

	}
	return columns;
}
 
Example #6
Source File: ExcelExportOfTemplateUtil.java    From easypoi with Apache License 2.0 4 votes vote down vote up
/**
 * 获取迭代的数据的值
 * @param cell
 * @param name
 * @return
 */
private List<ExcelTemplateParams> getAllDataColumns(Cell cell, String name) {
    List<ExcelTemplateParams> columns = new ArrayList<ExcelTemplateParams>();
    cell.setCellValue("");
    if (name.contains(END_STR)) {
        columns.add(new ExcelTemplateParams(name.replace(END_STR, EMPTY).trim(), cell
            .getCellStyle(), cell.getRow().getHeight()));
        return columns;
    }
    columns.add(new ExcelTemplateParams(name.trim(), cell.getCellStyle(), cell.getRow()
        .getHeight()));
    int index = cell.getColumnIndex();
    Cell tempCell;
    while (true) {
        tempCell = cell.getRow().getCell(++index);
        if (tempCell == null) {
            break;
        }
        String cellStringString;
        try {//允许为空,单表示已经完结了,因为可能被删除了
            cellStringString = tempCell.getStringCellValue();
            if (StringUtils.isBlank(cellStringString)) {
                break;
            }
        } catch (Exception e) {
            throw new ExcelExportException("for each 当中存在空字符串,请检查模板");
        }
        //把读取过的cell 置为空
        tempCell.setCellValue("");
        if (cellStringString.contains(END_STR)) {
            columns.add(new ExcelTemplateParams(cellStringString.trim().replace(END_STR, ""),
                tempCell.getCellStyle(), tempCell.getRow().getHeight()));
            break;
        } else {
            if (cellStringString.trim().contains(teplateParams.getTempParams())) {
                columns.add(new ExcelTemplateParams(cellStringString.trim(), tempCell
                    .getCellStyle(), tempCell.getRow().getHeight()));
            } else {
                //最后一行被删除了
                break;
            }
        }

    }
    return columns;
}