Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java POI cannot find symbol WorkbookFactory

im doing a conversion of the HSSF model to XSSF. Im getting lil errors here and there. I donwloaded the latest POI and dropped all the jar files in and did the apache includes in my java class.....getting this error:

import org.apache.poi.ss.usermodel.Workbook;

Workbook wb = WorkbookFactory.create();

275: cannot find symbol [javac] symbol : variable WorkbookFactory [javac] location: class mil.usmc.logcom.chassis.util.HSSFUtils [javac] Workbook wb = WorkbookFactory.create();

like image 266
Doc Holiday Avatar asked Sep 10 '12 17:09

Doc Holiday


2 Answers

If the question you are asking is how do you find the WorkbookFactory class, that's a good question. WorkbookFactory apparently does not reside in the poi.jar - it is in the poi-ooxml jar.

Add this dependency to your maven project and you should be able to import WorkbookFactory:

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.9</version>
</dependency>
like image 130
brettjonesdev Avatar answered Nov 01 '22 22:11

brettjonesdev


There is no zero-arg method for WorkbookFactory.create(). For example:

InputStream inp = new FileInputStream("workbook.xlsx");
Workbook wb = WorkbookFactory.create(inp);
like image 39
Reimeus Avatar answered Nov 01 '22 23:11

Reimeus