File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes error reading excel file using apache poi Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "error reading excel file using apache poi" Watch "error reading excel file using apache poi" New topic

error reading excel file using apache poi

Priya Bhagat

Joined: Jul 27, 2009
Posts: 2
I am trying to read data from excel file but it is giving me the following error:

Exception in thread "main" org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. POI only supports OLE2 Office documents
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(
at Test.displayFromExcel(
at Test.main(

I am using Apache HSSF-POI version 3.2-FINAL-20081019.
My file has .xls extension.
Any idea what's wrong?
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 39543
POI apparently suspects that it is not an XLS file, but an XLSX file - is it? If so, you need to use the POI 3.5 beta version (which supports Office Open XML - something POI 3.2 does not do).

Ping & DNS - updated with new look and Ping home screen widget
Priya Bhagat

Joined: Jul 27, 2009
Posts: 2
Hi Dittmer,

Thank you for your reply. Actually i wasn't using a correct file type. I was appending .xls extension to an Open Office org file preveously so only it was giving that error.
I tried with a MS-Excel (2003) file then it's working fine.
I agree. Here's the link:
subject: error reading excel file using apache poi
Similar Threads
Problem in reading macros of Exel file
ClassCastExcepiton Using POI
How to read excel file of 2MB and having around 200 sheets
Exception in thread "main" java.lang.IllegalArgumentException: Your InputStream was neither an OLE2
How to read xlsx file from local java file