mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-02 20:02:49 +08:00
fix alias
This commit is contained in:
parent
efedd36696
commit
b4568dd2e3
@ -7,6 +7,7 @@
|
||||
|
||||
### 新特性
|
||||
* 【core 】 ListUtil、MapUtil、CollUtil增加empty方法
|
||||
* 【poi 】 调整别名策略,clearHeaderAlias和addHeaderAlias同时清除aliasComparator(issue#828@Github)
|
||||
|
||||
### Bug修复
|
||||
* 【json 】 修复解析JSON字符串时配置无法传递问题
|
||||
|
@ -200,7 +200,6 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
||||
*/
|
||||
public ExcelWriter reset() {
|
||||
resetRow();
|
||||
this.aliasComparator = null;
|
||||
this.headLocationCache = null;
|
||||
return this;
|
||||
}
|
||||
@ -426,6 +425,8 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
||||
*/
|
||||
public ExcelWriter setHeaderAlias(Map<String, String> headerAlias) {
|
||||
this.headerAlias = headerAlias;
|
||||
// 新增别名时清除比较器缓存
|
||||
this.aliasComparator = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -437,6 +438,8 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
||||
*/
|
||||
public ExcelWriter clearHeaderAlias() {
|
||||
this.headerAlias = null;
|
||||
// 清空别名时清除比较器缓存
|
||||
this.aliasComparator = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -467,6 +470,8 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
||||
}
|
||||
this.headerAlias = headerAlias;
|
||||
headerAlias.put(name, alias);
|
||||
// 新增别名时清除比较器缓存
|
||||
this.aliasComparator = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -450,15 +450,26 @@ public class ExcelWriteTest {
|
||||
rows.add(tempList);
|
||||
}
|
||||
ExcelWriter writer = ExcelUtil.getWriter("D:\\test\\multiSheet.xlsx", "正常数据");
|
||||
writer.addHeaderAlias("1", "row1");
|
||||
writer.addHeaderAlias("3", "row2");
|
||||
writer.setOnlyAlias(true);
|
||||
|
||||
writer.write(rows, true);
|
||||
writer.autoSizeColumnAll();
|
||||
|
||||
//表2
|
||||
writer.setSheet("当前重复数据");
|
||||
writer.clearHeaderAlias();
|
||||
writer.addHeaderAlias("3", "行3");
|
||||
writer.addHeaderAlias("1", "行1");
|
||||
writer.write(rows, true);
|
||||
writer.autoSizeColumnAll();
|
||||
|
||||
//表3
|
||||
writer.setSheet("历史重复数据");
|
||||
writer.write(rows, true);
|
||||
writer.autoSizeColumnAll();
|
||||
|
||||
writer.close();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user