将数据先导成文本文件,然后用EXCEL的宏语言进行读入,速度绝对惊人,
可以是你以前的数百倍

解决方案 »

  1.   

    如果是ADO就直接用
    procedure adoquerytoexcel(Aadoquery:TCustomADODataSet) ;
    var
      XLApp: Variant;
      i:integer;
      Sheet: Variant;
    begin
      if Aadoquery.IsEmpty then exit;
     //    if Aadoquery.RecordCount=0 then exit;
         XLApp:= CreateOleObject('Excel.Application');
         XLApp.Visible := True;
         XLApp.Workbooks.Add(-4167);
         XLApp.Workbooks[1].WorkSheets[1].Name :='ϵͳÊý¾Ý';
         Sheet := XLApp.Workbooks[1].WorkSheets['ϵͳÊý¾Ý'];    for i := 1 to Aadoquery.fieldcount do
         begin
            Sheet.Cells[1, i] :=Aadoquery.fields[i-1].FieldName;
          end;
        sheet.cells[2,1].copyfromrecordset(AAdoQuery.recordset);
    end;
    很快的,
    BDE倒的方法也有很多,讨论的贴子也不少,你找一下就可以看到了。
      

  2.   

    你先转变成txt文件,在excel直接打开就可以了,不用什么转换的
    procedure TForm14.DataSetToASCII(const ADataSet: TDataSet; const ASCIIFile: TFileName; const Delimiter: Char; const QuoteStrings: Boolean);var tmpList: TStringList;
          i,LastIndex: LongInt;
          AsciiRecord: String;
      begin
        tmpList:= TStringList.Create;
           try
              with ADataSet do begin
            LastIndex:= Fields.Count - 1; 
                First;
              while not EOF do begin
              AsciiRecord:= '';
                   for i := 0 to LastIndex do 
                if Fields.Fields[i].Tag = 0 then begin 
      
                  if QuoteStrings and 
                     (Fields.Fields[i].DataType in [ftString,ftMemo,ftFmtMemo,ftFixedChar,ftWideString]) then 
                    AsciiRecord:= AsciiRecord + QuotedStr(Fields.Fields[i].AsString) 
                  else 
                    AsciiRecord:= AsciiRecord + Fields.Fields[i].AsString; 
      
                  if i < LastIndex then 
                    AsciiRecord:= AsciiRecord + Delimiter; 
      
                end; 
      
              tmpList.Append(AsciiRecord); 
      
              Next 
            end 
          end; 
      
          try
            tmpList.SaveToFile(ASCIIFile+'.txt') ;
          except 
            ShowMessage('Could not save table to specified file: ' + ASCIIFile) 
          end; 
      
        finally 
          tmpList.Free; 
        end; 
      end;
      

  3.   

    to yuanjunjing(★★★★★---※挪威森林※) :
    有几个地方不明白:
    XLApp.Workbooks.Add(-4167);   -4167是何含义?
    '&Iuml;&micro;&Iacute;&sup3;&Ecirc;&yacute;&frac34;&Yacute;'有特殊意义吗?
      

  4.   

    哎,想着倒这个就烦。如果有些格式要求,更麻烦。
    quick report的专业版有个excel filter,能做到你想要的,不过
      

  5.   

    不过...那是有格式的Excel,不能完成统计的操作。
      

  6.   

    可不可以直接存为Excel文件再打开呢???丰破烂
      

  7.   

    直接存成Excel文件再打开是可以的,
     但是在用Excel打开所存的文件时,总是提示格式不对,
    不知为什么?(用ADOQuery.SaveToFiles('abc.xls'))
    但是用F1book直接存成Excel就可以。