OleContainer1调用excel的问题
数据库中是用下面保存的 
var
  Stream :TMemoryStream;
begin
    Stream :=TMemoryStream.Create;
    OleContainer1.SaveToStream(Stream);
  with adoquery1 do
  begin
      Close;
      SQL.Clear;
      SQL.Add('select * from SJTTMB where 1=2');
      Prepared :=True;
      Open;
      Append;
      TBlobField(FieldByName('TMMC')).LoadFromStream(Stream);
      Post;
  end;
    
end; 
在读取excel的时候没问题,可是当点击窗体上的 edit1框的时候,OleContainer1就会自动释放,怎么让它不自动释放,高手帮助解决一下 
MySQL := 'select * from SJTTMB where Txid=4 and sfsc=0 and xh = 8';
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Text := MySQL;
    Open;
    TBlobField(FieldByName('TMMC')).SaveToFile('d:\abc.xls'); //先在D盘建立一个 abc.xls 文件
  end;
  OleContainer1.LoadFromFile('d:\abc.xls');
  OleContainer1.DoVerb(0);//改为OleContainer1.DoVerb(1);也不行

解决方案 »

  1.   

    是得到失去焦点的问题,楼主可以自己动态创建一个试试
    begin
      OleContainer2 :=  TOleContainerAc.Create(Self);
      OleContainer2.Parent := Self;
      OleContainer2.AllowInPlace := True;
      OleContainer2.Left := 10;
      OleContainer2.Top := 40;
      OleContainer2.Width := 600;
      OleContainer2.Height := 400;
      OleContainer2.Visible := True;
      TOleContainerAc(OleContainer2).CannotDeactivate := True;
      Button1.Enabled := true;
      Button2.Enabled := true;
    end;
      

  2.   

    filePath := AppPath + 'Temp\' + Filename;
            try
              if FileExists(filePath) then deleteFile(filePath);
              TBlobField(FieldByName('Content')).SaveToFile(filePath);//存储到临时目录
            except
              MessageBox(handle, '文件打开错误', '错误', MB_ICONWARNING);
              Exit;
            end;
        if FileExists(filePath) then
            f := TfrmEditDoc.Create(self);
            f.oleDoc.CreateObjectFromFile(filePath, false);//建立OLE对象
            f.oleDoc.DoVerb(0);// 进入编辑状态这是我程序中的部分代码,你看看我是将文件存储到本地临时文件,然后再建立OLE对象!