Java POI cannot find symbol WorkbookFactory

家住魔仙堡 提交于 2019-12-06 17:13:59

问题


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();


回答1:


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

InputStream inp = new FileInputStream("workbook.xlsx");
Workbook wb = WorkbookFactory.create(inp);



回答2:


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>


来源:https://stackoverflow.com/questions/12356463/java-poi-cannot-find-symbol-workbookfactory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!