//EhLib
//uses DBGridEhImpExp
procedure TDBMDIChildForm.DataSetExportExecute(Sender: TObject);
//导出数据
var
ExpClass:TDBGridEhExportClass;
Ext:String;
begin
inherited;
if not DBG.DataSource.DataSet.Active then exit;
if dlgSave.Execute then
begin
case dlgSave.FilterIndex of
1: begin ExpClass := TDBGridEhExportAsText; Ext := 'txt'; end;
2: begin ExpClass := TDBGridEhExportAsCSV; Ext := 'csv'; end;
3: begin ExpClass := TDBGridEhExportAsHTML; Ext := 'htm'; end;
4: begin ExpClass := TDBGridEhExportAsRTF; Ext := 'rtf'; end;
5: begin ExpClass := TDBGridEhExportAsXLS; Ext := 'xls'; 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,DBG,
dlgSave.FileName,not DBG.CheckCopyAction);
end;
end;
end;