Apache POI Parsing error

后端 未结 1 1893
礼貌的吻别
礼貌的吻别 2020-12-06 06:45

I know this question has been asked often, but couldn\'t find a suitable solution. When working with

XWPFDocument xdoc = new XWPFDocument(srcFile);
<         


        
相关标签:
1条回答
  • 2020-12-06 07:13

    From the Apache POI FAQ:

    Can I mix POI jars from different versions?

    No. This is not supported.

    All POI jars in use must come from the same version. A combination such as poi-3.11.jar and poi-ooxml-3.9.jar is not supported, and will fail to work in unpredictable ways.

    Your pom has dependencies on Apache POI jars from 3.11, 3.12 and 3.13, which as the FAQ explained isn't supported

    You need to change all of those to be 3.13, then it'll work

    I'd suggest something like:

    <properties>
      <poi.version>3.13</poi.version>
    </properties>
    <dependencies>
      <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>${poi.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-scratchpad</artifactId>
        <version>${poi.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>${poi.version}</version>
      </dependency>
      <!-- etc as needed -->
    

    That way, you can ensure all your POI jars are from the same version!

    0 讨论(0)
提交回复
热议问题