3
触发场景描述 子类属性ExcelIgnore注解覆盖了父类属性,未生效
easy-excel版本
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.1</version>
</dependency>
触发Bug的代码
@Data
static class Humen{
@ExcelProperty("名字")
private String name;
@ExcelProperty("电话")
private String phone;
}
@Data
static class Man extends Humen{
@ExcelProperty("地址")
private String addr;
@ExcelIgnore
private String phone;
}
public static void main(String[] args) throws IOException {
Man man = new Man();
man.setAddr("武汉");
man.setName("张三");
man.setPhone("123456");
ExcelWriter excelWriter = EasyExcel.write(Files.newOutputStream(new File("aaa.xlsx").toPath()), Man.class).build();
WriteSheet writeSheet = EasyExcel.writerSheet("test").build();
excelWriter.write(Collections.singletonList(man), writeSheet);
// 千万别忘记finish 会帮忙关闭流
excelWriter.finish();
}
提示的异常或者没有达到的效果 未正常忽略已覆盖字段