首页 > 代码库 > DBGridEh导出
DBGridEh导出
procedure ExportGridEh(DBGridEh:TDBGridEh);
var
ExpClass:TDBGridEhExportClass;
Ext:String;
dlgsave:TSaveDialog;
begin
dlgsave:= TSaveDialog.Create(nil);
begin
dlgsave.Filter:=‘Microsoft Excel|*.xls|CSV (Comma delimited)|*.csv|Text|*.txt|Web‘ +
‘ Page|*.htm|Rich Text Format(RTF)|*.rft‘;
if not dlgsave.Execute then Exit;
case dlgsave.FilterIndex of
1: begin ExpClass := TDBGridEhExportAsXLS; Ext := ‘xls‘; end;
2: begin ExpClass := TDBGridEhExportAsCSV; Ext := ‘csv‘; end;
3: begin ExpClass := TDBGridEhExportAsText; Ext := ‘txt‘; end;
4: begin ExpClass := TDBGridEhExportAsHTML; Ext := ‘htm‘; end;
5: begin ExpClass := TDBGridEhExportAsRTF; Ext := ‘rtf‘; 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,DBGridEh,dlgsave.FileName,true);
end;
end;
end;
DBGridEh导出