var
ExpClass:TDBGridEhExportClass;
Ext:String;
s_name:string;
begin
SaveDialog1.FileName := 'name';
// if (ActiveControl is TDBGridEh) then
if SaveDialog1.Execute then
begin
case SaveDialog1.FilterIndex of
1: begin ExpClass := TDBGridEhExportAsxls; Ext := 'xls'; end;
else
ExpClass := nil; Ext := '';
end;
if ExpClass <> nil then
begin
if UpperCase(Copy(SaveDialog1.FileName,Length(SaveDialog1.FileName)-2,3)) <> UpperCase(Ext) then
SaveDialog1.FileName := SaveDialog1.FileName + '.' + Ext;
s_name:= extractfilename(SaveDialog1.FileName);
SaveDBGridEhToExportFile(ExpClass,DBGridEh5,SaveDialog1.FileName,true);
end;
end;
ShellExecute(0,'open','EXCEL.EXE',pchar(s_name),nil,SW_SHOW);
前几天才做了这样一个功能,是参考别人的,希望你能有用