打开一个EXE文件可以用winexec
但打开一个excel文件是怎么操作的呢(要可以多次打开的,比如是打开了一个1.xls,之后关闭了这个文件,又可以再次打开)?谢谢!!

解决方案 »

  1.   

    很简单,把excel以流的形式存进数据库中,
    用OLE控键打开就可以了。
      

  2.   

    ShellExecute(Self.handle,'open','C:\1.xls','','',SW_SHOWNORMAL);
    uses
     shellapi;
      

  3.   

    下面得例子是使用动态创建的方法,也可以用DELPHI控件,这两种方法都可以通过程序控制excel得读写,如果只是打开,使用
    ShellExecute(Self.handle,'open','C:\1.xls','','',SW_SHOWNORMAL);就可以了unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,ComObj;//注意这里uses comobjtype
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
    ExcelApp: Variant;begin
    ExcelApp := CreateOleObject('Excel.Application');
    ExcelApp.Visible := True;
    ExcelApp.WorkBooks.Open( 'E:\Documents and Settings\aa.xls' );
    //ExcelApp.quit; 在需要得时候退去excel
    end;end.