修复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

@ -18,6 +18,7 @@
* 【core 】 修复PunyCode处理域名的问题pr#2620@Github * 【core 】 修复PunyCode处理域名的问题pr#2620@Github
* 【core 】 修复ObjectUtil.defaultIfNull去掉误加的deprecatedissue#I5SIZT@Gitee * 【core 】 修复ObjectUtil.defaultIfNull去掉误加的deprecatedissue#I5SIZT@Gitee
* 【core 】 修复ReflectUtil 反射方法中桥接判断问题issue#2625@Github * 【core 】 修复ReflectUtil 反射方法中桥接判断问题issue#2625@Github
* 【poi 】 修复ExcelWriter导出List<Map>引起的个数混乱问题issue#2627@Github
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------

View File

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