文件名称:java读取.xlxs Excel文件
文件大小:2KB
文件格式:JAVA
更新时间:2020-10-14 07:12:27
java读取xlxs Excel文件
File file = new File("C:/Users/admin/Desktop/菜单.xlsx"); InputStream is = new FileInputStream(file); XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is); // 获取每一个工作薄 for (int numSheet = 0; numSheet < xssfWorkbook.getNumberOfSheets(); numSheet++) { XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(numSheet); if (xssfSheet == null) { continue; } // 获取当前工作薄的每一行 for (int rowNum = 1; rowNum <= xssfSheet.getLastRowNum(); rowNum++) { XSSFRow xssfRow = xssfSheet.getRow(rowNum); if (xssfRow != null) { XSSFCell one = xssfRow.getCell(0); //读取第一列数据 XSSFCell two = xssfRow.getCell(1); //读取第二列数据 XSSFCell three = xssfRow.getCell(2); //读取第三列数据 System.out.println(three); } } }