请问各位老大,怎么样才能把DELPHI中的DBGIRD中的数据导出到EXCEL中,进行编辑!!!谢谢!!!

解决方案 »

  1.   

    用这个过程吧
    procedure  writetoexcel(bm:tdataset);
      procedure  writetoexcel(bm:tdataset);
      var jls0,zds0:integer;
          i,j:integer;
      begin
        app:=createoleobject('excel.application');
        app.visible:=true;
        app.workbooks.add;
        zds0:=bm.fieldcount;
        jls0:=bm.recordcount;
        bm.first;
       for i:=1 to zds0 do
          begin
           app.cells(1,i):=bm.fields[i-1].FieldName;
          end;
       for i:=2 to jls0+1 do
          begin
            for  j:=1 to zds0 do
              begin
                app.cells(i,j):=bm.fields[j-1].asstring;
              end;
            bm.Next;
          end;
      end;
      

  2.   

    你能做个例子给我发过来吗?chenqiang_200878(泥泥)
      

  3.   

    把上面的过程记下下面要调用它,  
    if (dm.Query1.Active=true) and (dm.Query1.RecordCount>=1) then
        writetoexcel(dm.Query1);