ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.WorkBooks.Open( excelfile_OpenDialog.FileName );
if Excelapp.Cells[1,1].Value<>'XX'  then aa
if Excelapp.Cells[1,2].Value<>'XX'  then  bb
if Excelapp.Cells[1,3].Value<>'XX'  then  cc
问题:第三句开始没反应啊,直接就then aa 了根本没判断  ,value的值提取不出来,哪里错了还是什么了····  

解决方案 »

  1.   

    还有就是excelApp.WorkBooks.Open ,Excelapp.Cells 我按excelapp.的时候也不会自动弹出显示,但是这样打又可以编译不报错 
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      ExcelApp:Variant;
    begin
      ExcelApp := CreateOleObject( 'Excel.Application' );
      try
        ExcelApp.Visible:=False;
        ExcelApp.WorkBooks.Open('D:\1.xls');
        if Excelapp.Cells[1,1].Value<>'XX' then showmessage('aa');
        if Excelapp.Cells[1,2].Value<>'XX' then showmessage('bb');
        if Excelapp.Cells[1,3].Value<>'XX' then showmessage('cc');
      finally
       ExcelApp.quit;
      end;
    end;沒有問題,很正常
      

  3.   

    我发现了···我的'xx'跟excel表里面的大小写不一样··恍然大悟··晕死了搞了我好久···你再回答下我输入excelApp.的时候怎么不会自动弹出下面显示什么
      

  4.   

    肯定不会自动弹出啊! 就算你输入excelApp.t1234567 := '123456';
    也可以编译过去!还有在最后ExcelApp.quit后还要加一句  ExcelApp := Unassigned;
    不加这一句的话!Excel不会正常退出的!你可以试试不加这句
    看看内存当中是不是存在一个excel进程!
      

  5.   

    在导出Excel时,最好不要打开Excel。
    导出时,正在写Excel时,不要动鼠标、键盘,
    也就要等写完Excel之后,再去操作电脑!