tags:

views:

117

answers:

3

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

A: 

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.

wobblycogs
can u tell me how to use Apache POI, i dont have the required jar
Simran
Wow, that's a huge question. I suggest you check out the quick guide http://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.
wobblycogs
A: 

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  A: 

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();
prateek urmaliya