Bug 51031 - Exception in thread "main" java.lang.IllegalArgumentException: Your InputStream was neither an OLE2 stream, nor an OOXML stream
Summary: Exception in thread "main" java.lang.IllegalArgumentException: Your InputStre...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: POIFS (show other bugs)
Version: 3.5-FINAL
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-06 07:47 UTC by Ram
Modified: 2011-04-06 08:01 UTC (History)
0 users



Attachments
Sample Excel File (58.91 KB, application/vnd.ms-excel)
2011-04-06 07:47 UTC, Ram
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ram 2011-04-06 07:47:16 UTC
Created attachment 26861 [details]
Sample Excel File

My client requirement is  to upload an Excel File (which is generated from another system). To upload this generated Excel File, I am using Apache POI api. The following jar files are in the classpath of my application.

dom4j-1.6.1
ooxml-schemas-1.0
poi-3.5-FINAL
poi-ooxml-3.5-FINAL
xmlbeans-2.3.0
openxml4j-1.0-beta.jar

I am getting the following exception(using Apache POI3.5)

Exception in thread "main" java.lang.IllegalArgumentException: Your InputStream was neither an OLE2 stream, nor an OOXML stream
        at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:65)
        at PoiExcelRead.main(PoiExcelRead.java:22)


when my code is

17    public static void main(String[] args) throws IOException, InvalidFormatException {
18 // TODO Auto-generated method stub
19
20 String xlsPath = "d://BOM70914831.xls";
21 InputStream myxls = new FileInputStream(xlsPath);
22 Workbook workBook = WorkbookFactory.create(myxls);
23    }



and I am getting the following exception(using Apache POI3.0)

Exception in thread "main" java.io.IOException: Invalid header signature; read 0x6D78206C6D74683C, expected 0xE11AB1A1E011CFD0
        at org.apache.poi.poifs.storage.HeaderBlockReader.<init>(HeaderBlockReader.java:120)
        at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:151)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:317)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:298)
        at PoiExcelRead.main(PoiExcelRead.java:22)

when my code is
17    public static void main(String[] args) throws IOException {
18 // TODO Auto-generated method stub
19
20 String xlsPath = "d://BOM70914831.xls";
21 InputStream myxls = new FileInputStream(xlsPath);
22 HSSFWorkbook wb     = new HSSFWorkbook(myxls);
23    }


Please find the sample excel file(BOM70914831.xls) to check my issue as an attachment.

Note: It is working when I open the file using Microsoft Excel and saving it as another file(using File>Save As option from Microsoft Excel Menu)
Comment 1 Nick Burch 2011-04-06 07:52:06 UTC
The clue's in the exception message - your file is neither a .xls file nor a
.xlsx one. If you open it in a text editor, you'll see that instead it's
HTML!
Comment 2 Ram 2011-04-06 08:01:08 UTC
(In reply to comment #1)
> The clue's in the exception message - your file is neither a .xls file nor a
> .xlsx one. If you open it in a text editor, you'll see that instead it's
> HTML!

Nick Burch,

Thanks for your reply. Can you please suggest any other solution.

Rgds,
Ram