maven依赖
<dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.10-FINAL</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.10-FINAL</version> </dependency>
解析
InputStream is = new FileInputStream(new File(url)); Workbook workBook = WorkbookFactory.create(is); Sheet sheet = workBook.getSheetAt(0); int rowcount = sheet.getPhysicalNumberOfRows(); for (int i = 1; i < rowcount; i++) { Row row = sheet.getRow(i); for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) { System.out.println(row.getCell(j)); } }