我用query   查询一组数据,现在需要一条一条的 输出到一个 notepad 中去.请问怎么调用notepad
怎么输出 .还有 希望输出一条后能过回车换行输入

解决方案 »

  1.   

    把数据写入*.txt,然后保存,不就可以了吗?
      

  2.   

    创建TStringList。把字段值读进去,然后SaveToFile就可以了。
      

  3.   

    同意楼上的,将数据保存成一个txt文件后,再用notepad+参数来调用即可
      

  4.   

    就是楼上的 rockswj(石头,我要学Sql) ( ) 信
      

  5.   

    就是呀,现在这样的贴子多得很,你可以找一下,怎么导入到TXT然后再怎么打开什么的,
    上面几位的就是正确方法
    先读到一个STRINGLIST是一个捷径,可以直接SAVETOFILE的~~
      

  6.   

    提供你一个StringList的例子procedure TQueryF.PrintLandUser(Printing : boolean);  function FormatStr(s : string; StrLength :integer):string;
      var
        Temp : string;
        i : integer;
      begin
        Temp := '';
        try
          for i := 1 to StrLength do
            Temp := Temp +' ';
          for i:= 1 to Length(s) do
            Temp[(StrLength-Length(s))div 2 +i] := s[i];
          Result := Temp;
        except
          Result := s;
        end;
      end;var
      PrintList : TStringList;
      i : integer;
      LinesCount : integer;
      PriUserID : string;
      f : TextFile;
    begin
      if Printing = False then
        if (not SaveDialog1.Execute) then
          Exit;
      PrintList := TStringList.Create;
      LinesCount := 0;
      if ListView3.Items.Count >0 then
        PriUserID := ListView3.Items[0].Caption
      else PriUserID := '';
      i := 0;
      while i <= ListView3.Items.Count-1 do
      begin
        if LinesCount = 0 then
        begin
          PrintList.Add('   <'+ListView3.Items[i].Caption+':'+
                        ListView3.Items[i].SubItems.Strings[0]+
                        '>没归还图书清单');
          Inc(LinesCount);
          PrintList.Add('                     打印时间:'+DateToStr(Date));
          Inc(LinesCount);
          PrintList.Add('');
          Inc(LinesCount);
          PrintList.Add('  图书号  |  借出时间  | 持有时间/天 |  罚金/元  ');
          Inc(LinesCount);
          PrintList.Add('----------------------------------');
          Inc(LinesCount);
        end;
        if PriUserID = ListView3.Items[i].Caption then
        begin
          PrintList.Add(FormatStr(ListView3.Items[i].SubItems.Strings[3],14)+'|'+
                        FormatStr(ListView3.Items[i].SubItems.Strings[4],16)+'|'+
                        FormatStr(ListView3.Items[i].SubItems.Strings[5],16)+'|'+
                        FormatStr(ListView3.Items[i].SubItems.Strings[7],16));
          Inc(LinesCount);
          Inc(i);
          if LinesCount > PrintLinesCount then
            PrintList.Add(#12);
        end
        else begin
          PriUserID := ListView3.Items[i].Caption;
          PrintList.Add('');
          PrintList.Add('   <'+ListView3.Items[i].Caption+':'+
                        ListView3.Items[i].SubItems.Strings[0]+
                        '>没归还图书清单');
          Inc(LinesCount);
          PrintList.Add('                     打印时间:'+DateToStr(Date));
          Inc(LinesCount);
          PrintList.Add('');
          Inc(LinesCount);
          PrintList.Add('  图书号  |  借出时间  | 持有时间/天 |  罚金/元  ');
          Inc(LinesCount);
          PrintList.Add('----------------------------------');
          Inc(LinesCount);
          Inc(LinesCount);// := 0;
        end;
      end;
      if Printing = False then
      try
        PrintList.SaveToFile(SaveDialog1.FileName);
      except
        MessageDlg('不能创建打印文件'+SaveDialog1.FileName,
                   mtError,[mbok],0);
      end;
      if Printing =True then
      begin
        AssignPrn(f);
        try
          Rewrite(f);
          for i := 0 to PrintList.Count-1 do
            Writeln(f,PrintList[i]);
          CloseFile(f);
        except
          MessageDlg('打印失败',mtError,[mbok],0);
          CloseFile(f);
        end;
      end;
      PrintList.Free;
      

  7.   

    先接受到一个memo中,然后
    memo1.lines.savetoFile(c:\a.txt);
      

  8.   

    可以输出到 text  中去  
    怎么调出来? 调出那个文件的语句怎么写?呵呵偶 是菜鸟啊
      

  9.   

    我靠,
    var slst:TStringList;
    begin
      slst:=TStringList.Create;
      slst.LoadFromFile(你的路径);//能SaveToFile就要LOadFromFile
    end;
      

  10.   

    哥哥 是我不好 没说清楚
    我的意思是 我现在靠各位大哥的指导 知道了如何输出数据到text 中去了比如 输出到 c:\1.text   可是 我现在不希望 每次点击 输出那个按钮后  自己到 c:\ 目录 底下去找那个1.text  我希望直接 出来了这个text  就是调用 windows  的  notepad  显示文件一样 
    不知道我表达的清楚不?
      

  11.   

    ShellExecute(0, 'open',PCHAR('NOTEPAD 'c:\1.text','','', SW_SHOW);
      

  12.   

    我再顶。
    uses ShellApi;ShellExecute(0, 'open','NOTEPAD', 'c:\1.txt', nil,SW_SHOW);