I was trying to connect my Java program with an Excel file. I have did upto this. But it throws this excepion
Unable to recognize OLE stream
Please, help me to complete this.
import jxl.*;
import java.io.*;
public class excel
{
public static void main(String[] args)throws Exception
{
File ex=new File("D:/worksps/test.xlsx");
Workbook w= Workbook.getWorkbook(ex);
Sheet s= w.getSheet(0);
for(int i=0;i<s.getColumns();i++)
{
for(int j=0;j<s.getRows();j++)
{
Cell cell=s.getCell(i, j);
System.out.println(" "+cell.getContents());
}
System.out.println("\n");
}
}
}
An OLE file can be seen as a mini file system or a Zip archive: It contains streams of data that look like files embedded within the OLE file. Each stream has a name. For example, the main stream of a MS Word document containing its text is named “WordDocument”. An OLE file can also contain storages.
JXL supports Excel worksheets created in Excecl 95/97 and 2000 -
Read the below in the official JXL site - http://www.andykhan.com/jexcelapi/
Features
Reads data from Excel 95, 97, 2000 workbooks Reads and writes formulas (Excel 97 and later only) Generates spreadsheets in Excel 2000 format
Your excel sheet seems to be created after Excel 2000. That seems to be the problem.
If you want to read Excel files created after Excel 2000 then you should use Apache POI. It is also an easy to use API and supports MS Excel 97 to MS Excel 2008.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With