unit Unit1;ide
interfacespa
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExcelWithOdbc, StdCtrls, DB, ADODB;orm
type
TForm1 = class(TForm)
Button1: TButton;
ExcelWithOdbc1: TExcelWithOdbc;
ADOQuery1: TADOQuery;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;it
var
Form1: TForm1;io
implementationclass
{$R *.dfm}im
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 ;db
DataItems.Items[0].DataSet := adoquery1 ;
DataItems.Items[0].OnlySelect := false ;
DataItems.Items[0].SelectFields := false ;
DataItems.Items[0].SheetName := '100條數據;di
Execute;
end;
end;
end.