mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
add test
This commit is contained in:
parent
2fb27b5dfb
commit
b8f0f7efdb
@ -1335,17 +1335,16 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
||||
}
|
||||
|
||||
final Map<Object, Object> filteredMap = MapUtil.newHashMap(rowMap.size(), true);
|
||||
String aliasName;
|
||||
for (Entry<?, ?> entry : rowMap.entrySet()) {
|
||||
aliasName = this.headerAlias.get(StrUtil.toString(entry.getKey()));
|
||||
rowMap.forEach((key, value)->{
|
||||
final String aliasName = this.headerAlias.get(StrUtil.toString(key));
|
||||
if (null != aliasName) {
|
||||
// 别名键值对加入
|
||||
filteredMap.put(aliasName, entry.getValue());
|
||||
filteredMap.put(aliasName, value);
|
||||
} else if (false == this.onlyAlias) {
|
||||
// 保留无别名设置的键值对
|
||||
filteredMap.put(entry.getKey(), entry.getValue());
|
||||
filteredMap.put(key, value);
|
||||
}
|
||||
}
|
||||
});
|
||||
return filteredMap;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package cn.hutool.poi.excel;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
@ -10,7 +11,7 @@ import java.util.Map;
|
||||
public class Issue2221Test {
|
||||
|
||||
@Test
|
||||
//@Ignore
|
||||
@Ignore
|
||||
public void writeDuplicateHeaderAliasTest(){
|
||||
final ExcelWriter writer = ExcelUtil.getWriter("d:/test/duplicateAlias.xlsx");
|
||||
// 设置别名
|
||||
|
Loading…
Reference in New Issue
Block a user