📄 unit2.pas
字号:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls,adodb,db;
type
TForm2 = class(TForm)
Memo1: TMemo;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses unit1,toexcel;
{$R *.dfm}
procedure TForm2.SpeedButton2Click(Sender: TObject);
begin
close;
end;
procedure TForm2.SpeedButton1Click(Sender: TObject);
var
sltquery:tadoquery;
dbs:tdatasource;
begin
if memo1.Text='' then
begin
messagedlg('没有定义查询语句,无法导出结果',mtinformation,[mbok],0);
exit;
end
else
begin
try
dbs:=tdatasource.Create(nil);
sltquery:=tadoquery.Create(nil);
sltquery.Connection:=form1.adoconnstr;
sltquery.SQL.Clear;
sltquery.SQL.Text:=memo1.Text;
sltquery.Open;
dbs.DataSet:=sltquery;
savexls(self.Handle,dbs,pchar('导出结果'));
messagedlg('导出成功!',mtinformation,[mbok],0);
dbs.Free;
sltquery.Free;
except
messagedlg('系统导常请检查自定SQL语句或者数据库连接串',mtinformation,[mbok],0);
dbs.Free;
sltquery.Free;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -