Access数据库里的数据怎么样才能转换成Excel?

解决方案 »

  1.   

    笨一点的,可先能过数据库控件把access中内容读出来,再存到excel中
      

  2.   

    用ADOTABLE,DBGRID把ACCESS打开,再用以下程序:
    导出到Excel表格:
    procedure Tf_Normal.ExportToExcel(DbGrid: TDBGrid; Query: TAdoQuery;ExcelApp:variant);
    var
      i,j,FieldNum:integer;
    begin
      with Query do
      begin
        DisableControls;
        fieldNum := dbgrid.fieldCount;
        for i:=1 to fieldNum do                          //写表头
        begin
          ExcelApp.Cells[1,i]:=Fields[i-1].FieldName;
        end;
        first;
        i:=2;
        while not eof do
        begin
          for j:=1 to fieldNum do
          begin
            ExcelApp.Cells[i,j]:=fields[j-1].AsString;
          end;
          inc(i);
          if (i mod 20)=0 then
          ExcelApp.Cells[i+10,1].Activate;
          next;
        end;
        EnableControls;
      end;
    end;
    procedure Tf_Normal.ButtonClick(Sender: TObject);
    var
      ExcelApp: variant;
    begin
      application.ProcessMessages;
      try
        ExcelApp:=createoleobject('Excel.application');
      except
        messageDlg('请先安装MicroSoft Excel',mtError,[mbok],0);
        exit;
      end;
      ExcelApp.Visible := True;
      ExcelApp.Caption := '名字';
      ExcelApp.WorkBooks.Add;
      ExcelApp.WorkSheets[1].Activate;
      ExcelApp.WorkSheets[1].name:='表名';
      ExcelApp.ActiveSheet.Rows[1].Font.Bold:= True;
      ExcelApp.Columns[1].NumberFormatLocal:='@';
      ExportToExcel(DbGrid: TDBGrid; Query: TAdoQuery;ExcelApp:variant);
      ExcelApp.WorkBooks.Close;
      ExcelApp.Quit;
    end;
      

  3.   

    不知你想在什么时候转化他,
    不用程序用delphi的datapump就行