ExcelWithOdbc控件的使用

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExcelWithOdbc, StdCtrls, DB, ADODB;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ExcelWithOdbc1: TExcelWithOdbc;
    ADOQuery1: TADOQuery;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  ADOQuery1.Close;
  ADOQuery1.SQL.Add('SELECT TOP 100 * FROM T1');
  ADOQuery1.Active := True;

  with ExcelWithOdbc1 do
  begin
    DataItems.Add;
    AutoGetFileName := true ;
    AutoOpen := True ;

    DataItems.Items[0].DataSet := adoquery1 ;
    DataItems.Items[0].OnlySelect := false ;
    DataItems.Items[0].SelectFields := false ;
    DataItems.Items[0].SheetName := '100条数据;

    Execute;
  end;
end;

end.


你可能感兴趣的:(windows,procedure,private,public)