java poi 生成word 并插入 表格

报错:

Exception in thread "main" java.lang.IncompatibleClassChangeError: Found interface org.apache.poi.util.POILogger, but class was expected
 

原因: poi 引入的版本不一样

解决办法:  更换统一版本或兼容版本

代码会在 另一篇文章中,贴出来

我的pom:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!--<dependency>-->
        <!--<groupId>org.apache.poi</groupId>-->
        <!--<artifactId>poi-ooxml</artifactId>-->
        <!--<version>3.14</version>-->
    <!--</dependency>-->

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-excelant</artifactId>
        <version>3.14</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-examples</artifactId>
        <version>4.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml-schemas</artifactId>
        <version>3.10-FINAL</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>4.0.0</version>
    </dependency>

   <!--Apache poi  在word中的表格中插入表格,图片等操作  开始-->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>4.0.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans</artifactId>
        <version>3.1.0</version>
    </dependency>

    <dependency>
        <groupId>com.deepoove</groupId>
        <artifactId>poi-tl</artifactId>
        <version>1.6.0-beta1</version>
    </dependency>
    <!--结束-->


    <!--<dependency>-->
        <!--<groupId>org.apache.xmlbeans</groupId>-->
        <!--<artifactId>xmlbeans</artifactId>-->
        <!--<version>2.6.0</version>-->
    <!--</dependency>-->
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-commons</artifactId>
        <version>RELEASE</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.4</version>
    </dependency>

    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.9.4</version>
    </dependency>

    <dependency>
        <groupId>jacob</groupId>
        <artifactId>jacob</artifactId>
        <scope>system</scope>
        <systemPath>${basedir}/lib/jacob.jar</systemPath>
    </dependency>

    <dependency>
        <groupId>ooxml-schemas</groupId>
        <artifactId>ooxml-schemas</artifactId>
        <scope>system</scope>
        <systemPath>${basedir}/lib/ooxml-schemas-1.1.jar</systemPath>
    </dependency>

    <dependency>
        <groupId>spire.doc.free-2.7.3</groupId>
        <artifactId>spire.doc.free-2.7.3</artifactId>
        <scope>system</scope>
        <systemPath>${basedir}/lib/spire.doc.free-2.7.3.jar</systemPath>
    </dependency>

</dependencies>
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐