I am referencing the version 3.7 of the Apache POI and I am getting a \"cannot be resolved\" error when I do:
import org.apache.poi.xssf.usermodel.XSSFWorkbo
The classes for the OOXML file formats (such as XSSF for .xlsx) are in a different Jar file. You need to include the poi-ooxml jar in your project, along with the dependencies for it
You can get a list of all the components and their dependencies on the POI website here.
What you probably want to do is download the 3.11 binary package, grab the poi-ooxml
jar from it, and the dependencies in the ooxml-lib
directory. Import these into your project and you'll be sorted.
Alternately, if you use Maven, you can see here for the list of the artificats you'll want to depend on, but it'd want to be something like:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
The poi-ooxml maven dependency will pull in the main POI jar and the dependencies for you automatically. If you want to work with the non-spreadsheet formats, you'd also want to depend on the poi-scratchpad
artifact too, as detailed on the POI components page
If you use Maven:
poi => poi-ooxml in artifactId
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.12</version>
</dependency>
I Got the Solution Guys
You need to keep some points in your mind .
There are two different dependency one is (poi) & other dependency is (poi- ooxml) but make sure you must use poi-ooxml dependency in your code.
Just Add the following dependency in pom.xml & Save it.
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
3 .After you have saved the pom.xml then you need to try a small thing ,Use (.) operator will try to import/fetch it & finally will not see any sort of error because now it has imported that thing in your package.
Sample Code to Understand Better !!
package ReadFile;// package
import org.apache.poi.xssf.usermodel.XSSFWorkbook; // automatically added to your code after importing
public class Test
{
public static void Hello() // Method
{
XSSFWorkbook workbook = new XSSFWorkbook();
}
}
I tried my best to give you the solution , If you face any issue comment here i will try
to solve it .
Keep Learning Guys !!
You did not described the environment, anyway, you should download apache poi libraries. If you are using eclipse , right click on your root project , so properties and in java build path add external jar and import in your project those libraries :
xmlbeans-2.6.0 ; poi-ooxml-schemas- ... ; poi-ooxml- ... ; poi- .... ;
For OOXML to work you need the POI-OOXML jar which is separately packaged from the POI jar.
Download the POI-OOXML jar from the following location -
http://repo1.maven.org/maven2/org/apache/poi/poi-ooxml/3.11/poi-ooxml-3.11.jar
For Maven2 add the below dependency -
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>