22

In my app I have used Apache POI 3.8 for XLS file processing.

Now I want to migrate to Apache POI 3.9 latest and stable version. I have added the JAR file poi-3.9-20121203.jar in my application and removed JARs related to POI 3.8.

But it seems that, in 3.9 version, the WorkbookFactory class has been removed.

So how can I create a Workbook with WorkbookFactory in Apache POI 3.9 ?

I extracted the JAR and checked, there is no class like WorkbookFactory.

Can anyone tell me how to create a new workbook with POI 3.9?

chrki
  • 6,143
  • 6
  • 35
  • 55
Gunjan Shah
  • 5,088
  • 16
  • 53
  • 72

2 Answers2

43

You're missing several JARs. Take a look at the POI Components Page and you'll see that you need the POI-3.9 jar, the POI-OOXML-3.9 jar, and their respective dependencies.

If you want to work with any of the other formats (eg doc, docx, ppt, pptx) you'll also need the POI-Scratchpad-3.9 jar. As you're working with the OOXML file formats (eg .xlsx), as shown in the components page, you'll need either the POI-OOXML_Schemas-3.9 jar, or the larger full OOXML-Schemas-1.1 jar.

Also, since this question was asked, there have been two new releases of Apache POI, with lots of bugs fixed and new features added, so it's worth using the latest version (3.11 as of writing) rather than 3.9!

Gagravarr
  • 47,320
  • 10
  • 111
  • 156
  • 4
    Thanks for the answer Gagravarr. Yes I missed one JAR file. That is POI-OOXML-3.9 jar. After adding that JAR, it works fine. – Gunjan Shah Dec 28 '12 at 16:54
  • 2
    If you use maven, then the following should get you what you need org.apache.poi poi 3.11 org.apache.poi poi-ooxml 3.11 – Mr. Port St Joe May 03 '15 at 16:56
  • For those who are using sbt, just add the following line in your build.sbt `libraryDependencies += "org.apache.poi" % "poi-ooxml" % "3.12` – gkc Oct 06 '15 at 13:02
  • Not that it's totally necessary but for completeness, if you are using Gradle: compile("org.apache.poi:poi:3.15") compile("org.apache.poi:poi-ooxml:3.15") – c.dunlap Mar 31 '17 at 16:51
  • @c.dunlap You shouldn't need the first - the `poi-ooxml` artifact depends on the core POI jar so will put it in automatically for you – Gagravarr Mar 31 '17 at 18:10
  • @Gagravarr That's true. I just needed the dependency on poi before I ended up needing the dependency on ooxml so I had both in my gradle file once I figured this one out. – c.dunlap Apr 01 '17 at 19:20
1

I would be surprised that they made such breaking change without mentioning it in the list of changes...

And indeed, I can see the WorkbookFactory in the JavaDoc, which I suppose are up-to-date with the latest version.

Perhaps you can show some simple code that worked in 3.8 and no longer works in 3.9, along with the error message(s) you get. The problem might not be what you think...

PhiLho
  • 40,535
  • 6
  • 96
  • 134
  • 1
    Thanks for the answwer PhiLho. Here I missed to view require dependent JAR files. We need to add POI-OOXML-3.9 jar file with PPI 3.9. jar file. It works fine now. – Gunjan Shah Dec 28 '12 at 16:56