我正在尝试在Java中读取一个简单的.xlsx:
private void readExcelData(String excel) throws Exception {
FileInputStream file = new FileInputStream(excel);
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet sheet = workbook.getSheetAt(0);
}
但是我在线程中收到以下异常:
"AWT-EventQueue-0" java.lang.IncompatibleClassChangeError: Found interface org.apache.poi.util.POILogger, but class was expected
我必须添加xmlbeans-2.6.0.jar或它给我:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
也许与此有关。我还添加了编译和运行时依赖项,就像在这里建议的那样:https://mvnrepository.com/artifact/org.apache.poi/poi/4.1.0 但这并不能解决我的问题
有人可以解决吗?
答案 0 :(得分:2)
愚蠢的错误。我没有添加最新版本的poi-oomxml