如果用delphi代的控件做的关闭时就加上:
    eworkbook.Close;
    eapp.Disconnect;
    eapp.Quit;
如果是用ole做的关闭时加上:
    exapp.workbooks.close;
    exapp.quit;
    exapp:=unassigned

解决方案 »

  1.   

    修改try...except之间的内容为如下:procedure TFrm_Laozi.Button1Click(Sender: TObject);
    var
      I,J : integer;
    begin
      if not VarIsEmpty(exl_app) then
      begin
        exl_app.activework.close;
        exl_app.DisplayAlerts := true;  // 7Discard unsaved files....
        try
          exl_Sheet.close;
          exl_app.Application.quit;
          exl_app := Unassigned;
          exl_Sheet := Unassigned;
        except
          Application.MessageBox('无法正常关闭Microsoft Excel','系统信息',MB_OK+MB_ICONWARNING);
        end;
      end;
    ……
    ……