1
votes

I'm trying to make an XSSFWorkbook like this

File file = new File(fileName);
Workbook workbook = new XSSFWorkbook(file);

But I get the error:

The constructor XSSFWorkbook(File) is undefined

I checked here: http://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFWorkbook.html and it says that there is a constructor that takes files

XSSFWorkbook(java.io.File file)
Constructs a XSSFWorkbook object from a given file.

Why isn't it working?

2
I couldn't think of anything other than asking you to check if the poi jars are in your build path.raj
might be a poi jar version issue. You might be using old version.Sanjeev
The JavaDocs on the Apache POI website always refer to the latest version. Most likely you're running an older one / have older jars than you meant on your classpath. Can you try upgrading your POI version?Gagravarr
In 3.9, there's no constructor which takes a File. Make sure you use either the latest version or use a constructor that is available in your version.Jonathan Drapeau
I downloaded version 3.10 from here: poi.apache.org/download.html and added poi, poi-ooxml, and even poi-ooxml-shemas(not sure if I need this one) to my build path. HSSFWorkbook works fine but the XSSFWorkbook still says the constructor is undefined.LazerWing

2 Answers

1
votes

Use...

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.10.1</version>
</dependency>
1
votes

Try using 3.14. It works for me!!