Code
procedure TForm1.Button3Click(Sender: TObject);
var ExpClass:TDBGridEhExportClass;
Ext,strDate:String;
begin
strDate:=formatdatetime('yyyy',DataTimer.DateTime)+formatdatetime('mm',DataTimer.DateTime)+formatdatetime('dd',DataTimer.DateTime-1);
SaveDialog1.FileName := '考勤检查记录'+strDate;
if SaveDialog1.Execute then
begin
case SaveDialog1.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 := 'html'; end;
//5: begin ExpClass := TDBGridEhExportAsRTF; Ext := 'rtf'; 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;
SaveDBGridEhToExportFile(ExpClass,dbjg,
SaveDialog1.FileName,true);
end;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var ExpClass:TDBGridEhExportClass;
Ext,strDate:String;
begin
strDate:=formatdatetime('yyyy',DataTimer.DateTime)+formatdatetime('mm',DataTimer.DateTime)+formatdatetime('dd',DataTimer.DateTime-1);
SaveDialog1.FileName := '考勤检查记录'+strDate;
if SaveDialog1.Execute then
begin
case SaveDialog1.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 := 'html'; end;
//5: begin ExpClass := TDBGridEhExportAsRTF; Ext := 'rtf'; 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;
SaveDBGridEhToExportFile(ExpClass,dbjg,
SaveDialog1.FileName,true);
end;
end;
end;
useing DBGridEhImpExp;