“无法识别OLE流” excel连接到Excel时 [英] "Unable to recognize OLE stream" excepion while connecting to Excel

查看:1583
本文介绍了“无法识别OLE流” excel连接到Excel时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的Java程序与Excel文件相连接。我已经做到了这一点。但是它抛出了这个例子

I was trying to connect my Java program with an Excel file. I have did upto this. But it throws this excepion


无法识别OLE流

Unable to recognize OLE stream

请帮我完成这个。

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");
       }
      }
}


推荐答案

JXL支持在Excecl 95/97和2000中创建的Excel工作表 -

JXL supports Excel worksheets created in Excecl 95/97 and 2000 -

请阅读官方JXL网站中的以下内容 - http://www.andykhan.com/jexcelapi/

Read the below in the official JXL site - http://www.andykhan.com/jexcelapi/


功能

从Excel中读取数据95,97,2000
工作簿读取和写入公式
(Excel仅限97和更高版本)以Excel 2000格式生成
电子表格

Reads data from Excel 95, 97, 2000 workbooks Reads and writes formulas (Excel 97 and later only) Generates spreadsheets in Excel 2000 format

您的Excel表格似乎是在Excel 2000之后创建的。似乎是问题。

Your excel sheet seems to be created after Excel 2000. That seems to be the problem.

如果要阅读Excel 2000之后创建的Excel文件,那么您应该使用Apache POI。它也是一个易于使用的API,并支持MS Excel 97到MS Excel 2008。

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.

这篇关于“无法识别OLE流” excel连接到Excel时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆