1

i am trying to read an Excel file using Java code however i am getting following error :

jxl.read.biff.BiffException: Unable to recognize OLE stream

when i searched on net i found jExcel supports only upto excel 2003, and this error comes when excel is made in 2007 bt i have saved my excel in 97-2003 format only and i am still getting this problem

3 Answers 3

9

JExcel API does not support excel 2007,you can use Apache POI HSSF/XSSF

here is sample code for Reading and Rewriting Workbooks from the site

InputStream inp = new FileInputStream("workbook.xls");
//InputStream inp = new FileInputStream("workbook.xlsx");

Workbook wb = WorkbookFactory.create(inp);
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(2);
Cell cell = row.getCell(3);
if (cell == null)
    cell = row.createCell(3);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue("a test");

// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
Sign up to request clarification or add additional context in comments.

Comments

0

I've no experience of JExcel but I beleive you are correct in thinking that the problem is one of file formats. I suggest you try the Apache POI project. I use it extensively to read and write Excel spreadsheets. It will read any spreadsheet created from Excel 5.0 onwards IIRC and supports both .xsl and .xslx file types.

2 Comments

can u tell me how to use Apache POI, i dont have the required jar
Wow, that's a huge question. I suggest you check out the quick guide poi.apache.org/spreadsheet/quick-guide.html it covers the basics of getting started with POI. As for getting the required jars the site provides a download or you can do as I do and download it using Maven.
-1

I am using JExcel since long time but never got this kind of problem. I think your file is not in XLS format. You try to create a new Excel file and try to read it.

1 Comment

Answer is not related to the question at all. Simran has already mentioned that problem occurs when she saved XlSX file as XLS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.