USES 
cxgridExportlink
procedure TfrmAdvAPS.CxGridToExcel(AcxGrid: TcxGrid);
var
  SaveDialog: TSaveDialog;
begin
  SaveDialog := TSaveDialog.Create(nil);
  try
    with SaveDialog do
    begin
      FileName := '导出';
      Filter := '*.xls|*.xls|*.xlsx|*.xlsx|';
      if Execute then
      begin
        case SaveDialog.FilterIndex of
          1:
            ExportGridToExcel(SaveDialog.FileName, AcxGrid, true, true, true, 'xls');
          2:
            ExportGridToXLSX(SaveDialog.FileName, AcxGrid, true, true, true, 'xlsx');  //2007
        end;
      end;
    end;
  finally
    SaveDialog.Free;
  end;
end;

 

posted on 2021-07-28 14:48  redhat588  阅读(220)  评论(0编辑  收藏  举报