阿里巴巴的easyexcel工具是一种不太占用太多内存的excel读取工具,相比起apache的excel工具来说,easyexcel还是不错的。
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>1.1.2-beat1</version>
</dependency>
首先是maven配置。
首先先建立一个ExcelData类继承 BaseRowModel 类
package com.jlau.algsystem.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
/**
* Created by cxr1205628673 on 2020/5/8.
*/
public class XlsMonitorData extends BaseRowModel{
@ExcelProperty(value = "采样日期",index = 1)
private String time;
@ExcelProperty(value = "省名称",index = 2)
private String province;
@ExcelProperty(value = "市名称",index = 3)
private String city;
@ExcelProperty(value = "县名称",index = 4)
private String county;
@ExcelProperty(value = "乡(镇)名称",index = 5)
private String countryside;
@ExcelProperty(value = "村名称",index = 6)
private String village;
@ExcelProperty(value = "农户名称",index = 7)
private String name;
@ExcelProperty(value = "地块名称",index = 8)
private String block;
@ExcelProperty(value = "北纬",index = 9)
private Double latitude;
@ExcelProperty(value = "东经",index = 10)
private Double longitude;
@ExcelProperty(value = "海拔",index = 11)
private Double altitude;
@ExcelProperty(value = "pH",index = 12)
private Double pH;
@ExcelProperty(value = "有机质",index = 13)
pr