如何将数据库中的数据导出成EXCEL文件

解决方案 »

  1.   

    什么数据库,如果是SQL用DTS。如是在程序中控制用  uses variantsvar
      ExcelApp,Sheet:olevariant;    ExcelApp:=CreateOleObject('Excel.Application');
        ExcelApp.visible:=true;
        ExcelApp.workbooks.add;
        ExcelApp.workbooks[1].worksheets[1].name:=head.title;
        Sheet:=ExcelApp.workbooks[1].worksheets[1];
      

  2.   

    xlreport,什麼數據庫都可以方便導出
      

  3.   

    procedure TForm2.DataToExcel;
    var 
      I,II: Integer;
    begin
      try
      Excelapplication1.Visible[0]:=true;
      try
      Excelworkbook1.ConnectTo(Excelapplication1.Workbooks.Add(EmptyParam,0));
      except
      raise Exception.Create('鏈接到Excel文件出錯,可能是沒有安裝Excel文件');
      end;
        Excelworksheet1.ConnectTo(excelworkbook1.Worksheets[1] as _worksheet);
      begin    //--1
          ExcelWorksheet1.Name:=str;
           with Excelworksheet1.QueryTables.Add(adoquery1.Recordset,Excelworksheet1.Range['A2',EmptyParam],EmptyParam) do
           begin
             FieldNames := False;
             Refresh(False);
           end;    // with
    finally
      end;
    end;
      

  4.   

    http://community.csdn.net/Expert/topic/3132/3132748.xml?temp=.8100855