<!--引入poi-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.0.0</version>
</dependency>
String strUrl = "E:\\test.xlsx";
//根据路径获取当前excel
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(new FileInputStream(strUrl));
//excel工作表会有多个这里默认读取第一个工作表
XSSFSheet sheet = xssfWorkbook.getSheetAt(0);
//获取0的总行数下表为0
int row = sheet.getLastRowNum();
for (int num = 0; num <= row; num++) {
//读取第0行依次排列赋值
System.out.println( sheet.getRow(row).getCell(0));
}