Click here to Skip to main content
16,017,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to read an excel file in java. I hava downloaded the jxl.jar file and I have set classpath in eclipse.But Iam not able to execute the program because it throws BiffException. Like this:
jxl.read.biff.BiffException: Unable to recognize OLE stream
    at jxl.read.biff.CompoundFile.<init>(CompoundFile.java:116)
    at jxl.read.biff.File.<init>(File.java:127)
    at jxl.Workbook.getWorkbook(Workbook.java:221)
    at jxl.Workbook.getWorkbook(Workbook.java:198)
    at excel.read(excel.java:40)
    at excel.main(excel.java:69)

May I know why it is throwing exception and how can I resolve this.
Posted
Updated 27-Feb-20 1:13am
v2
Comments
Nountylegre 25-Feb-19 8:45am    
Try this Excel library for Java:

import com.gembox.spreadsheet.*;
// ...

ExcelFile ef = ExcelFile.load("SimpleTemplate.xlsx");

// Iterate through all worksheets in an Excel workbook.
for (ExcelWorksheet sheet : ef.getWorksheets()) {
// Iterate through all rows in an Excel worksheet.
for (ExcelRow row : sheet.getRows()) {
// Iterate through all allocated cells in an Excel row.
for (ExcelCell cell : row.getAllocatedCells()) {
System.out.println(cell.getValue());
}
}
}

The code is from this example for reading Excel file in Java.

An Excel workbook with several sheets (from BIFF5 on) is stored using the compound document file format (also known as OLE2 storage file format or Microsoft Office compatible storage file format). It contains several streams for different types of data.
A complete documentation of the format of compound document files can be found at

http://sc.openoffice.org/compdocfileformat.pdf[^]

I think the exception mean that your parsing library can not recognise it(For example:biff5 format can not be parsed in POI and Jexcelapi). You can check your file version be open it in Office and click 'SAVE AS',the format list in the filedialog is it's current file version.
 
Share this answer
 
v2
BiffException means that the jexcel api is not able to recognize the file format and the file u r using. I was also facing the same issue in Office 2010.

Then i resolved the problem by just saving the file as office 2003-7 .xls file. It may b problem in office10 or other case but if u will save file as office 2003-7 then I hope ur code will also work.
 
Share this answer
 
v2
I faced the similar error while reading the file name using below syntax in JAVA

Workbook objworkBook = Workbook.getWorkbook(file);


Solution: In my case, I just corrected the column names in the uploaded template and now it's working fine
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900