Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues resolving XSSFWorkbook - Java - POI .jar

Tags:

I'm trying to do work upgrading a Java application to handle .xlsx, using a newer POI library than our existing one. I'm having issues similar to those mentioned in the comments to the answer here: Apache POI, using both XSSF and HSSF

I'm pointing the new ss.usermodel, but it keeps telling me it can't resolve the XSSF workbook declaration:

Workbook xlsImport = new XSSFWorkbook(); 

I dug through some of their documentation and saw that XSSFWorkbook isn't a part of org.apache.poi.ss.usermodel. It's a part of org.apache.poi.xssf.usermodel.XSSFWorkbook. But there's no poi.xssf for me to import. Am I pointing to the wrong thing? I'm using POI 3.7 Thanks for any help you can provide.

like image 922
Nick Avatar asked Feb 17 '11 15:02

Nick


People also ask

What is XSSFWorkbook in Java?

XSSFWorkbook − This class has methods to read and write Microsoft Excel and OpenOffice xml files in . xls or . xlsx format. It is compatible with MS-Office versions 2007 or later.

Do we need to close XSSFWorkbook?

Constructs a XSSFWorkbook object from a given file. Once you have finished working with the Workbook, you should close the package by calling close() , to avoid leaving file handles open.

Does XSSF support XLS?

XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (. xlsx) file format. HSSF and XSSF provides ways to read spreadsheets create, modify, read and write XLS spreadsheets.


2 Answers

You need to include the poi-ooxml jars to get the XSSF library. The poi jar only has the HSSF libraries.

like image 197
Joe Kearney Avatar answered Oct 01 '22 09:10

Joe Kearney


You need to include poi-ooxml jars. You can add it to pom.xml file

<dependency>     <groupId>org.apache.poi</groupId>     <artifactId>poi-ooxml</artifactId>     <version>3.10-FINAL</version> </dependency> 
like image 43
Peter T. Avatar answered Oct 01 '22 08:10

Peter T.