💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
```java @RequestMapping("/excel/read") public void read(@RequestParam("file") MultipartFile file) throws IOException { //创建文档 XSSFWorkbook workbook = new XSSFWorkbook(file.getInputStream()); //获取表格 XSSFSheet sheet = workbook.getSheetAt(0); //获取总行数 int rows = sheet.getPhysicalNumberOfRows(); for (int i = 0; i < rows; i++) { //获取行 XSSFRow row = sheet.getRow(i); //获取每一行的总列数 int cols = row.getPhysicalNumberOfCells(); for (int k = 0; k < cols; k++) { //获取列 XSSFCell cell = row.getCell(k); //获取值 String value = cell.toString(); System.out.println(value); } } } ```