各位大虾 !!帮忙啊
解决方案 »
- SPCOMM 接收数据 中间漏一字节
- 怎样在点击按钮2以后,就能够停止点击按钮1后正在进行的工作?
- CoXMLHTTP30在哪个单元文件里?oReq := CoXMLHTTP30.Create; 这句为什么老出错?
- 各个不同年龄阶段女孩的心,及她们是如何看待男孩?
- memo定位首行的问题
- 赶在2004年最后一天把婚结了,开心,散分!呵呵!
- delphi fortran 混合编程
- delphi编写webservice中加入socket
- 我说什么来,请进……
- 有关LoadPicture函数.
- delphi/java base 技术论坛。给大家一个交流空间
- 各位朋友,我知道你们只关心技术,其实我也一样
slist:tstringlist;
begin
slist := tstringlist.create;
query.first;
for i := 0 query.recordcount -1 do
begin
slist.add(query.fieldbyname('1').asstring + query.fieldbyname('2').asstring + .. );
query.next;
end;
slist.savetofile(filename)
slist.free;
end;
1、使用batchmove
2、使用quickreport,在报表中加入TTextFileter控件,这样报表就支持
另存为txt格式。
3、ehlib在expert.csdn.net就有
3、使用循环
//把输出结果转换成文本文件
function ChangetoText(TextForm:Tform;Query1:TQuery;title:string;summary:string): Boolean;
var
I: integer;
FName,OutString: string;
OutFile: TextFile;
note: Tbook;
savedialog1: Tsavedialog;
begin
//创建对话框的容器
try
savedialog1 := Tsavedialog.Create(TextForm);
//Assign a filename to the variable
savedialog1.Filter := 'Text files (*.txt)|*.TXT';
if savedialog1.Execute then
FName := savedialog1.FileName+'.txt';
if FName <> '' then
begin
note := Query1.GetBook;
Query1.DisableControls; //Identify the filename and type as OutFile
AssignFile(OutFile,fname); //create and open a new file identify as OutFile
Rewrite(OutFile); //插入标题
OutString := title+#13;
Writeln(OutFile,OutString);
OutString := ''; //Get text from the Query1
for I:=0 to Query1.FieldCount-1 do
begin
if query1.Fields[i].Visible = True then
begin
OutString:=OutString+Query1.Fields[i].displaylabel;
if I < Query1.FieldCount-1 then
OutString := OutString + ','
else outstring := Outstring;
end;
end;
Writeln(OutFile,OutString);
OutString := ''; While not Query1.EOF do
begin
for I:=0 to Query1.FieldCount-1 do
begin
if query1.Fields[i].Visible = True then
begin
OutString:=OutString+'"'+Query1.Fields[i].AsString+'"';
if I < Query1.FieldCount-1 then
OutString := OutString + ','
else outstring := Outstring ;
end;
end;
//Write out the text in OutString to file
Writeln(OutFile,OutString);
Query1.Next;
OutString := '';
end; //插入总结
Writeln(OutFile,summary);
//Update and close the file
CloseFile(OutFile);
Query1.EnableControls;
Query1.GotoBook(note);
Query1.FreeBook(note);
savedialog1.Destroy;
result := True;
end;
except
CloseFile(OutFile);
Query1.EnableControls;
Savedialog1.free;
Showmessage('过程错误,请退出后重新运行!');
Result := False;
end;
end;
table1.first;
while not table1.eof do
begin
with table1 do
str1:=fields[0].asstring;
str2:=fields[1].asstring;
str3:=fields[2].asstring;
wreiteln(mytextfile,str1,str2,str2);
next;
end;
end;
效率是慢了一点,查过以前的资料,并没有更好的办法。
begin
open;
first;
while not eot do
begin
for i:=i to fieldcount-1 do
begin
s:=fields[i].astring;
write(F,s);
end;
write(F,#13);
end;
close;
end;
slist:tstringlist;
begin
slist := tstringlist.create;
query.first;
for i := 0 query.recordcount -1 do
begin
slist.add(query.fieldbyname('1').asstring + query.fieldbyname('2').asstring + .. );
query.next;
end;
slist.savetofile(filename)
slist.free;
end;