NoClassDefFoundError org/apache/poi/ss/usermodel/Workbook

﹥>﹥吖頭↗ 提交于 2019-12-05 19:58:26

As per this Apache POI FAQ entry, mixing POI jars between different versions is not supported and will break in all sorts of ways, such as the one you've found. Don't do it!

You need to be using your POI jars all from the same release. I'd suggest the latest version, available here (currently 3.15)

You should probably also review the components and their dependencies page, to ensure you've got all the required jars for your use of Apache POI. Well, or use a dependency management tool like Maven or Gradle to handle that for you!

I have downloaded the latest Apache POI binaries v3.17 here and it has all the required jars to create xlsx file and open with out any fuss.

Required jars are shown in below screenshots (refer to selected jars) FYR.

poi 2.5.1 had no such package (and consequently a class) included (you can verify by unpacking the jar files as they are essentially zip archives). See the source.

Update the poi dependency to release 3. This also has the added benefit of matching the ooxml version.

For apache poi to work, you need compatible jars. I used these jars

      <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi</artifactId>
             <version>3.9</version>
      </dependency>
      <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-ooxml</artifactId>
             <version>3.9</version>
      </dependency>
      <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-ooxml-schemas</artifactId>
             <version>3.9</version>
      </dependency>
      <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-scratchpad</artifactId>
             <version>3.9</version>
      </dependency>
      <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>ooxml-schemas</artifactId>
             <version>1.1</version>
      </dependency>
      <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>openxml4j</artifactId>
             <version>1.0-beta</version>
      </dependency>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!