cxgrid导出

uses 中添加 cxGridExportLink

procedure Tfrm_patient_fee_list.bar_daochuClick(Sender: TObject);
var
  SFD:TSaveDialog;
  FileName,FileExt:String;
begin
  SFD:=TSaveDialog.Create(nil);
  SFD.Filter:='Excel文件 (*.xls)|*.xls';
  SFD.Title:='导出为';
  SFD.DefaultExt:='.XLS';
  SFD.Options:=[ofOverwritePrompt, ofEnableSizing];

    if not SFD.Execute then exit;
    //filename
    FileName:=SFD.FileName;
    FileExt:=UpperCase(ExtractFileExt(FileName));

    if FileExt='.XLS' then
    begin
      if rb_all.Checked then
        ExportGridToExcel(FileName, cxGrid_all, True, True)
      else if rb_day.Checked then
        ExportGridToExcel(FileName, cxGrid_day, True, True)
      else if rb_mingxi.Checked then
        ExportGridToExcel(FileName, cxGrid_mingxi, True, True)
      else if rb_project.Checked then
        ExportGridToExcel(FileName, cxGrid_project, True, True);
    end
    else
      begin
          Application.MessageBox('不支持的导出格式', 'xx');
          Exit;
      end;
    SFD.Free;
end;

你可能感兴趣的:(导出,cxgrid)