使用poi包里的类读取excel数据
maven依赖如下
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
注意:这个依赖不加可能会报错
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>
@Test
public void readArea() {
File file = new File("D:\\app\\area.xlsx");
ArrayList<String> rows = Lists.newArrayList();
try {
XSSFWorkbook wb = new XSSFWorkbook(new BufferedInputStream(new FileInputStream(file)));
Sheet sheet = wb.getSheetAt(0);
for (int i = 1; i < sheet.getLastRowNum() + 1; i++) {
XSSFRow row = (XSSFRow) sheet.getRow(i);
//row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
//row.getCell(1).setCellType(Cell.
读取excel数据工具类
于 2022-08-12 09:29:23 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)