搞错,不是这个控件,但你用这个控件的话我有导出代码。
procedure Tfrmcomsearch1.Button2Click(Sender: TObject);
var ExpClass:TDBGridEhExportClass;
Ext:String;
begin
DlgSave.FileName := 'file1';
// if (screen.ActiveControl is TDBGridEh) then
if DlgSave.Execute then
begin
case DlgSave.FilterIndex of
1: begin
ExpClass := TDBGridEhExportAsText;
Ext := 'XLS';
end;
2: begin
ExpClass := TDBGridEhExportAsCSV;
Ext := 'HTML';
end;
3: begin
ExpClass := TDBGridEhExportAsHTML;
Ext := 'TXT';
end;
else
ExpClass := nil;
Ext := '';
end;
if ExpClass <> nil then
begin
if UpperCase(Copy(DlgSave.FileName,Length(DlgSave.FileName)-2,3)) <>
UpperCase(Ext) then
DlgSave.FileName := DlgSave.FileName + '.' + Ext;
SaveDBGridEhToExportFile(ExpClass,DBGridEh1,
dlgsave.FileName,True)
end;
end;
end;