poi解析excel文件报错

时间:2024-08-29 20:07:38

getFileMagic() only operates on streams which support mark(int)

使用 bis 解决

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(path)));
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(bis);

找不到类,一般是版本问题,可以把版本调整一致,3.15

java.lang.reflect.InvocationTargetException

org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException

Java.lang.NoClassDefFoundError :org/openxmlformats/schemas/spreadsheetml/x2006/main/ctextensionlist

pom配置,版本保持一致,3.15

		<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.15</version>
</dependency>