我的代码如下:
var
  ExcelApp: Variant;
begin
   ExcelApp := CreateOleObject('Excel.application');
   ExcelApp.Visible := True;
   ExcelApp.Caption := 'Delphi调用 Microsoft Excel';
   ExcelApp.WorkBooks.Open(Filename:='D:\czcgl\test.xls');
end;

解决方案 »

  1.   

    var
        xlApp, xlWorkBook , xlSheet, szValue: Variant;
        OpenFileName : String ;
    begin
      If OpenDialog1.Execute Then Begin
        OpenFileName := OpenDialog1.FileName ;
          xlApp := CreateOleObject('Excel.Application');
          xlWorkBook := CreateOleObject('Excel.Sheet');      xlWorkBook := xlApp.Workbooks.Open(OpenFileName );
          xlSheet :=  xlWorkBook.Worksheets[1];
          xlApp.Visible := True ; 
    /////.......
      End ;
    End ;
      

  2.   

    我也碰到过,经随便修改一下文档后保存,就正确了。和Excel版本有关吧
      

  3.   

    var
      ExcelApp: Variant;
    begin
       ExcelApp := CreateOleObject('Excel.application');
       ExcelApp.Visible := True;
       ExcelApp.Caption := 'Delphi调用 Microsoft Excel';
       ExcelApp.WorkBooks.Open('D:\czcgl\test.xls');
    end;