这个容易不过,文本要有规律就可以了,不如字段间用TAB隔开,
然后把它读入就可以了,不过也可以用一个小技巧,就是将
这样有规律的文件作为Excel来对待,用Delphi的Server上的
关于excel的控键来读和写,具体的代码我有不过不在这个计算机上,
有空我贴上来。
然后把它读入就可以了,不过也可以用一个小技巧,就是将
这样有规律的文件作为Excel来对待,用Delphi的Server上的
关于excel的控键来读和写,具体的代码我有不过不在这个计算机上,
有空我贴上来。
解决方案 »
- CheckListbox
- 十六进制的几个数 $30 $23 $23 $45 $21 $24 $40 使用什么方法能把这些数据存成常量, 最好能存成字符串或者是字符数组.
- Delphi写MSSQL程序时,为什么我用TQuery控件打开一个表后再打开另一表时,再去关先打开的表要报错?
- 如何在DBGRID或者STRINGGRID中实现用滚轮进行翻页的功能,就象浏览网页一样?菜问题一个~
- 如何设置dbGrid每行的颜色?
- 有关TPrinter打印的问题,还请帮忙指点
- 关于事务的问题?
- DBgrid的Lookup问题,请大侠们帮手
- 如何实现每过一年数据库中的年龄字段自动加1
- 局域网共享问题,大家帮忙呀!谢谢!!!
- 怎样使两个treeview加载相同的节点
- 万分火急,在Delphi当中有没有象VB中的DATEADD这样的函数!!!!
/* 输出到文本文件 */
var
i,j,k:integer;
f2 :textfile;
aa:string;
begin
j:=query1.Fields.Count;
k:=query1.RecordCount;
if SaveDialog1.Execute then
AssignFile(F2, SaveDialog1.Filename);
Rewrite(F2);
query1.First;
for k:=k downto 1 do
begin
for i:=0 to j-1 do
begin
aa:=aa+'#'+query1.Fields.Fields[i].asstring;
end;
writeln(f2,aa);
query1.Next;
aa:='';
end;
CloseFile(F2);
while not eof(F) do begin
readln(strtmp,F);
for i:=1 to fieldNum do begin
position:=pos('#',strtmp);
otherstr:=copy(strtmp,1,position-1); //取出一个字段值
delete(strtmp,position); //从串删除该字段值,使后面的字段都顺序向前移
query1.Fields.Fileds[i].value:=otherstr;
query1.insert;
end; //
end;
procedure TForm1.Button2Click(Sender: TObject);
var f : textfile;
i,position : integer;
strtmp,otherstr,filename : string;
begin FileName := GetCurrentDir + '\fixempo.txt';
If FileExists(FileName) then
begin
AssignFile(F,FileName);
ReSet(F); table1.open;
while not eof(F) do
begin
readln(F,strtmp);
for i:=1 to 2 do
begin
position:=pos('#',strtmp);
otherstr:=copy(strtmp,1,position-1); //取出一个字段值
delete(strtmp,position,length(Otherstr)); //从串删除该字段值,使后面的字段都顺序向前移 table1.edit;
table1.Fields.Fields[i].value:=otherstr;
table1.post;
end; //
end;
end;
end;
var f : textfile;
i,position : integer;
strtmp,s,filename : string;
begin
FileName := GetCurrentDir + '\fixempo.txt';
If FileExists(FileName) then
begin
query1.close;
query1.sql.Clear;
query1.sql.Add('insert into FixEmpo(empoName,departname)');
query1.sql.Add('values(:empo,:depart)');
AssignFile(F,FileName);
ReSet(F); while not eof(F) do
begin
readln(F,strtmp);
while pos('#',strtmp) <> 0 do
begin
for i:= 1 to 2 do
begin
position:=pos('#',strtmp);
s := copy(strtmp,1,position-1); //取出一个字段值
Delete(strtmp,1,position); //从串删除该字段值,使后面的字段都顺序向前移
query1.Fields.Fields[i].value:= S;
query1.Insert;
end;
end;
end;
end;
end;