赞
踩
我在使用EasyExcel做单据导出的时候,发现导出的文件里面表头是完整展示了,但是表中的数据却一片空白。表头能完好展示说明我的@ExcelProperty、@ExcelIgnore 注解都起到作用了,但是字段中的数据展示不出来又是什么原因呢?
查阅了相关资料后,才知道了是字段命名的原因。EasyExcel调用的get方法 名字和@Data注解自动生产的get方法是不同的。
每个字段的第二个字母改为小写,如图所示:
这样的话 Getter and Setter 的方法名就是这样的:
- public String getForderNumber() {
- return forderNumber;
- }
-
- public void setForderNumber(String forderNumber) {
- this.forderNumber = forderNumber;
- }
-
- public LocalDateTime getForderTime() {
- return forderTime;
- }
-
- public void setForderTime(LocalDateTime forderTime) {
- this.forderTime = forderTime;
- }
-
- public String getFexportUser() {
- return fexportUser;
- }
-
- public void setFexportUser(String fexportUser) {
- this.fexportUser = fexportUser;
- }
结果:
数据也成功导出了!
改前和改后的 Getter and Setter的方法名对比
- //改前:fOrderNumber、fExportDepartment、......
- //失败
- public String getfOrderNumber() {return fOrderNumber;}
- public void setfOrderNumber(String fOrderNumber) {this.fOrderNumber = fOrderNumber;}
-
- public String getfExportDepartment() {return fExportDepartment;}
- public void setfExportDepartment(String fExportDepartment) {this.fExportDepartment = fExportDepartment;}
-
- //改后:forderNumber、fexportDepartment、......
- //成功
- public String getForderNumber() {return forderNumber;}
- public void setForderNumber(String forderNumber) {this.forderNumber = forderNumber;}
-
- public String getFexportDepartment() {return fexportDepartment;}
- public void setFexportDepartment(String fexportDepartment) {this.fexportDepartment = fexportDepartment;}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。