Java读Excel

img


这个excel表格,用Java可以将红框中的列读为行吗?使用什么工具可以进行读取

引入poi的相关依赖


```java
 <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
        </dependency>

public static void read (String fileName) throws IOException {
        //读取文件地址
        FileInputStream fileInputStream = new FileInputStream(new File("C:\\Users\\x\\Desktop\\"+fileName+".xlsx"));
        XSSFWorkbook excel = new XSSFWorkbook(fileInputStream);
        //读取文件中的哪一个表
        XSSFSheet sheet = excel.getSheet("gril");
        //获取某一行的内容 第一行 rownum=0
        XSSFRow row1 = sheet.getRow(1);
        //获取某一行中某一个的某一格的内容
        String name = row1.getCell(0).getStringCellValue();
        String age = row1.getCell(1).getStringCellValue();
        System.out.println(name+"--------------"+age);
        fileInputStream.close();
    }

```

用POI读
想怎么读都行
你可以自己控制底层的读写