private void setValueForCellByMap(Cell cell, Map<String, Object> map) throws Exception {
CellType cellType = cell.getCellTypeEnum();
if (cellType == CellType.STRING || cellType == CellType.NUMERIC) {
cell.setCellType(CellType.STRING);
String oldString = cell.getStringCellValue();
if (oldString != null && oldString.indexOf("{{") != -1 && !oldString.contains("fe:")) {
String params = null;
boolean isNumber = false;
if (this.isNumber(oldString)) {
isNumber = true;
oldString = oldString.replace("n:", "");
}
while(oldString.indexOf("{{") != -1) {
params = oldString.substring(oldString.indexOf("{{") + 2, oldString.indexOf("}}"));
oldString = oldString.replace("{{" + params + "}}", PoiElUtil.eval(params, map).toString());
}
if (isNumber && StringUtils.isNotBlank(oldString)) {
cell.setCellValue(Double.parseDouble(oldString));
cell.setCellType(CellType.NUMERIC);
} else {
cell.setCellValue(oldString);
}
}
if (oldString != null && oldString.contains("fe:")) {
this.addListDataToExcel(cell, map, oldString.trim());
}
}
}这里看着还是只有处理字符串的
private void setValueForCellByMap(Cell cell, Map<String, Object> map) throws Exception {
CellType cellType = cell.getCellTypeEnum();
if (cellType == CellType.STRING || cellType == CellType.NUMERIC) {
cell.setCellType(CellType.STRING);
String oldString = cell.getStringCellValue();
if (oldString != null && oldString.indexOf("{{") != -1 && !oldString.contains("fe:")) {
String params = null;
boolean isNumber = false;
if (this.isNumber(oldString)) {
isNumber = true;
oldString = oldString.replace("n:", "");
}