vo实体对象:
@Data
public class NodeMarginalPriceVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("节点名称")
@ExcelProperty(index = 1)
private String nodeName;
@ApiModelProperty("日期")
@ExcelProperty(index = 2)
private String date;
@ApiModelProperty("时点")
@ExcelProperty(index = 3)
private String time;
@ApiModelProperty(value = "电能量价格")
@ExcelProperty(index = 4)
private BigDecimal eEnergyPrice;
}
用easyExcel读取数据:
List<NodeMarginalPriceVo> voList = EasyExcel.read(file.getInputStream())
.sheet()
.head(NodeMarginalPriceVo.class).headRowNumber(2).doReadSync();
结果:voList实体对象集合中其余列都有值,唯独eEnergyPrice列的值是null。通过查阅资料,说实体对象必须遵循驼峰写法,否则识别不出来。但是eEnergyPrice也是驼峰写法呀?
最终解决:将eEnergyPrice属性名改为enEnergyPrice,即可解决问题。