修复ExcelWriter导出List<Map>引起的个数混乱问题

This commit is contained in:
Looly
2022-09-23 12:52:05 +08:00
parent 8d348b539d
commit f51df24970
2 changed files with 5 additions and 3 deletions

View File

@@ -1005,9 +1005,6 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public ExcelWriter writeRow(Object rowBean, boolean isWriteKeyAsHead) {
if (rowBean instanceof Iterable) {
return writeRow((Iterable<?>) rowBean);
}
Map rowMap;
if (rowBean instanceof Map) {
if (MapUtil.isNotEmpty(this.headerAlias)) {
@@ -1015,6 +1012,10 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
} else {
rowMap = (Map) rowBean;
}
}else if(rowBean instanceof Iterable){
// issue#2398@Github
// MapWrapper由于实现了Iterable接口应该优先按照Map处理
return writeRow((Iterable<?>) rowBean);
} else if (rowBean instanceof Hyperlink) {
// Hyperlink当成一个值
return writeRow(CollUtil.newArrayList(rowBean), isWriteKeyAsHead);