java - java.lang.NoSuchMethodError: org.apache.poi.util.POILogger.log(ILjava/lang/Object;)V
问题描述
从 excel(Office excel 2007 女士)文件中读取数据时出现以下错误。我正在使用 testNG 框架使用 selenium。
java.lang.NoSuchMethodError:
org.apache.poi.util.POILogger.log(ILjava/lang/Object;)V
我使用的 POI jar 如下:
<!-- 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();
}
解决方案
推荐阅读
- ruby-on-rails - Activeadmin - 显示页面内的表单仅显示提交按钮
- amazon-web-services - 亚马逊无服务器图像处理程序,CORS 问题
- python - 将 Excel 行从一个工作簿复制到另一个工作簿
- monitoring - 如何以毫秒分辨率而不是分钟分辨率存储从 Zabbix 代理收集的数据指标
- node.js - 如何使用 nodemailer 发送 html 文件
- ios - 设置委托时出现无效的选择器错误:Xcode 10 swift 4
- google-apps-script - Google 表格中的预测
- swift - 如何从 Firestore 中提取自定义对象?
- mysql - Laravel:如何将此 Sql 语句转换为 Eloquent 或 Query Builder?
- json - PostgreSQL 选择成 JSON 数组