Question

I'm trying to use POI to convert word files to the txt files , but when i use org.apache.poi.xwpf.usermodel.XWPFDocument it tells me that "cannot resolve xwpf"

my pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0         http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>convert</groupId>
<artifactId>convertor</artifactId>
<version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.10-FINAL</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.6.0</version>
        </dependency>

    </dependencies>

When I run clean & package it gives me success. How can I resolve this problem?

Was it helpful?

Solution

As per the Apache POI Components page, for XWPF you need the poi-ooxml maven artifact as a dependency

Your pom will therefore want to look something like this:

<properties>
    <poi.version>3.10-FINAL</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-ooxml</artifactId>
        <version>${poi.version}</version>
    </dependency>
</dependencies>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top