请问怎样在Delphi程序中实现将一个表中的符合条件的数据,也就是Query中的数据导出到一个文件中??

解决方案 »

  1.   

    tquery.savetofile  or
    select into .................
      

  2.   

    自己写一个啦,或者搜索一下,cvs,以前肯定有的。
      

  3.   

    先过滤:
    adoquery1.filtered:=false;
    adoquery1.filter:='field1=1';
    adoquery1filtered:=true;
    然后另存为XML文件:
    adoquery1.savetofile('aaa.xml',pfxml);
    ok!!!
      

  4.   

    我有能力帮助你,请看我站http://www.to-happy.com《大事》里的数据维护部分的导入。
      

  5.   

    可以将数据导出到excel中,你要吗???
      

  6.   

    如果是ADO的则可以直接用ADOQuery.SaveToFile如果是BDE的则只能一条一条往文件里写:
    (adqOutPut里是经过查询后得到的数据集)
    procedure OutPutFunction(adqOutPut: TQuery);
    var
      dlgsavAcc: TSaveDialog;
      F:textfile;
      strField, strExecSql:string;
      intFieldCount,i:integer;
    begin
      dlgsavAcc:=TSaveDialog.Create(nil);
      dlgsavAcc.Filter := 'Text files (*.txt)|*.TXT';
      with adqOutPut do
      begin
        if dlgsavAcc.Execute then
        begin
          if FileExists(dlgsavAcc.FileName) then
             if Application.MessageBox(pchar('是否现有文件覆盖'),pchar('提示'),MB_OKCANCEL)<>idok then
               Exit;
          assignfile(F,dlgsavAcc.FileName);
          Rewrite(F);
          intFieldCount:=adqOutPut.Fields.Count;
          while not Eof do
          begin
            strField:='';
            for i:=0 to intFieldCount-1 do
            begin
              if strField='' then
                strField:=Fields.Fields[i].AsString
              else
                strField:=strField+''','''+Fields.Fields[i].AsString;
            end;
            Writeln(F,strField);
            Next;
          end;
          CloseFile(F);
          Application.MessageBox(pchar('导出函数成功!'),pchar('提示'),MB_ICONINFORMATION);
      //          end;
        end
        else
          Exit;
      end;
      dlgsavAcc.Free;
    end;
      

  7.   

    要导出到什么类型的文件中??用dbgrideh,可以导出成excel,txt,rtf,htm等格式,或者也可以用写数据库的方式导成access格式。