dbgrideh 添加footer和导出

1.添加合计

dgh_patient.FooterRowCount := 1;    // 指定网格尾部统计行行数
 dgh_patient.SumList.Active := true;   // 激活统计
 dgh_patient.FooterColor := clBtnFace ; // 指定统计行颜色
 dgh_patient.Columns[5].Footer.ValueType := fvtStaticText;
 dgh_patient.Columns[5].Footer.Value := '合计:';
 dgh_patient.Columns[6].Footer.ValueType := fvtSum;

2.添加导出

uses DBGridEhImpExp;

procedure Tfrm_fee.bar_daochuClick(Sender: TObject);
var
 ExpClass:TDBGridEhExportclass;
 Ext:String;
 FSaveDialog: TSaveDialog;
begin
 try
   if not dm_fee_search.ado_receipt.IsEmpty then
   begin
     FSaveDialog := TSaveDialog.Create(Self);
     FSaveDialog.Filter:='Excel 文档 (*.xls)|*.XLS|Text files (*.txt)|*.TXT|Comma separated values (*.csv)|*.CSV|HTML file (*.htm)|*.HTM|Word 文档 (*.rtf)|*.RTF';
     if FSaveDialog.Execute and (trim(FSaveDialog.FileName)<>'') then
     begin
       case FSaveDialog.FilterIndex of
           1: begin ExpClass := TDBGridEhExportAsXLS; Ext := 'xls'; end;
           2: begin ExpClass := TDBGridEhExportAsText; Ext := 'txt'; end;
           3: begin ExpClass := TDBGridEhExportAsCSV; Ext := 'csv'; end;
           4: begin ExpClass := TDBGridEhExportAsHTML; Ext := 'htm'; end;
           5: begin ExpClass := TDBGridEhExportAsRTF; Ext := 'rtf'; end;
       end;
       if ExpClass <> nil then
       begin
         if UpperCase(Copy(FSaveDialog.FileName,Length(FSaveDialog.FileName)-2,3)) <> UpperCase(Ext) then
           FSaveDialog.FileName := FSaveDialog.FileName + '.' + Ext;
           if FileExists(FSaveDialog.FileName) then
           begin
             if application.MessageBox('文件名已存在,是否覆盖   ', '提示', MB_ICONASTERISK or MB_OKCANCEL)<>idok then
               exit;
           end;
          Screen.Cursor := crHourGlass;
          SaveDBGridEhToExportFile(ExpClass,dgh_patient,FSaveDialog.FileName,true);
          Screen.Cursor := crDefault;
          MessageBox(Handle, '导出成功  ', '提示', MB_OK +
            MB_ICONINFORMATION);
         end;
     end;
     FSaveDialog.Destroy;
   end;
 except
   on e: exception do
   begin
     Application.MessageBox(PChar(e.message), '错误', MB_OK + MB_ICONSTOP);
   end;
 end;
end;

你可能感兴趣的:(导出,footer,合计,dggrideh)