在Delphi中读取Excel电子表格

在Delphi中读取Excel电子表格,delphi,import-from-excel,Delphi,Import From Excel,我有许多应用程序可以读取Excel电子表格以转换为SQL 所有应用程序都基于相同的技术,使用以下步骤。直到最近在一个客户站点上安装为止,它工作得非常完美 程序 procedure TFormSpreadsheet.ConnectToExcel; var strConn : widestring; begin strConn:='Provider=Microsoft.Jet.OLEDB.4.0;' + 'Data Source=' + edtSpreadsheet.Te

我有许多应用程序可以读取Excel电子表格以转换为SQL

所有应用程序都基于相同的技术,使用以下步骤。直到最近在一个客户站点上安装为止,它工作得非常完美

程序

procedure TFormSpreadsheet.ConnectToExcel;
var strConn :  widestring;
begin
  strConn:='Provider=Microsoft.Jet.OLEDB.4.0;' +
           'Data Source=' + edtSpreadsheet.Text + ';' +
           'Extended Properties=Excel 8.0;';
  showmessage(strConn);
  ConnectionIn.Connected:=False;
  ConnectionIn.ConnectionString:=strConn;
  try
    ConnectionIn.Open;
  except
    ShowMessage('Unable to connect to Excel, make sure the workbook ' + edtSpreadsheet.Text + ' exists!');
    raise;
  end;
end;(*ConnectToExcel*)

procedure TFormSpreadsheet.FetchData;

begin
  StatusBar1.SimpleText:='';

  ConnectToExcel;

  QrySpreadsheetIn.Close;

  QrySpreadsheetIn.SQL.Text:=MemoQry.Text;
  showmessage('qry is ' + memoqry.Text);
  try
    QrySpreadsheetIn.Open;
    clientdataset1.Open;
  except
    ShowMessage('Unable to read data from Excel, make sure the query ' + edtSpreadsheet.Text +
                 ' is meaningful!');
    raise;
  end;
end;
在这个网站上,我收到一条消息“无法从Excel读取数据,请确保查询有意义”

查询内容为“从[sheetname$”中选择*

(适用于所有其他站点)

在客户站点上运行的Showmessages显示连接成功,但打开查询(我尝试过的每一次安装都可以使用)失败

其他资料-

该过程是在32位系统上用Delphi7开发的。 失败的安装在64位系统上,但我已成功安装在其他64位系统上

我已经读到,有一些DLL的,可能是失踪或不活动,但已由网站的IT公司保证,他们都应该在秩序

有人有什么想法吗?也许有些代码可以用来证明什么是错的


hanks提前请求任何帮助/建议

不幸的是,您的异常处理程序丢弃了所有有用的信息。您需要从异常中获取信息。