从excel(Ms office excel 2007)文件中读取数据时出现以下错误。我正在使用testNG框架处理硒。
java.lang.NoSuchMethodError:
org.apache.poi.util.POILogger.log(ILjava/lang/Object;)V
我正在使用的POI罐如下:
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
以下是我编写的代码:
try {
FileInputStream fin = new FileInputStream("E:/Automation/My
Study/Test Data.xlsx");
System.out.println(Runtime.class.getPackage().
getImplementationVersion());
workbook = new XSSFWorkbook(fin);
sheet = workbook.getSheet(sheetName);
outerHM= new HashMap<String, HashMap<String, String>>();
innerHM= new HashMap<String, String>();
int lastRow = sheet.getLastRowNum();
for(int i=1; i<=lastRow; i++) {
int lastCell = sheet.getRow(i).getLastCellNum();
for(int j=1; j<=lastCell; j++) {
innerHM.put(sheet.getRow(0).getCell(j).getStringCellValue(),
sheet.getRow(i).getCell(j).getStringCellValue());
}
System.out.println("Printing "+ innerHM);
outerHM.put(sheet.getRow(i).getCell(0).getStringCellValue(),
innerHM);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}