在预览返回的数据中增加header的mapList信息

This commit is contained in:
Zhaoyang 2020-03-06 14:46:42 +08:00
parent f3cd640ab3
commit 4bdc4237d6
2 changed files with 15 additions and 0 deletions

View File

@ -108,6 +108,7 @@ public abstract class BaseExcelFileController extends BaseFileController {
}
// 绑定属性到model
dataMap.put("header", listener.getHeadMap());
dataMap.put("fieldHeaders", listener.getFieldHeaders());
dataMap.put(ORIGIN_FILE_NAME, fileName);
dataMap.put(PREVIEW_FILE_NAME, newFileName);
List dataList = listener.getDataList();

View File

@ -186,6 +186,20 @@ public abstract class FixedHeadExcelListener<T extends BaseExcelModel> extends A
return this.fieldHeadMap;
}
public List<Map<String, String>> getFieldHeaders(){
if (V.isEmpty(this.fieldHeadMap)) {
return Collections.emptyList();
}
List<Map<String, String>> fieldHeaders = new ArrayList<>();
for (Map.Entry<String, String> fieldHead : this.fieldHeadMap.entrySet()) {
fieldHeaders.add(new HashMap<String, String>(){{
put("key", fieldHead.getKey());
put("title", fieldHead.getValue());
}});
}
return fieldHeaders;
}
/**
* 返回数据
* @return