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