L
lio_cheng
Unregistered / Unconfirmed
GUEST, unregistred user!
数据输出到excel,中文成乱码,下面是我的程序:
Function TForm1.ToExcel():boolean;
var
i : integer;
tslist:TStringList;
s : string;
aSheet,excel : Variant;
begin
result:=true;
Excel := CreateOleObject( 'Excel.Application' );
Excel.Visible:=true;
Excel.Workbooks.Add;
aSheet:=excel.Worksheets.Item[1];
tsList:=TStringList.Create;
try
try
with Query1do
begin
Open;
First;
While Not Eofdo
begin
s:='';
for i:=0 to FieldCount-1do
begin
s:=s+Fields.AsString+#9;
Application.ProcessMessages;
end;
tsList.Add(s);
next;
end;
close;
end;
clipboard.astext:= tslist.text;
except
result:=false;
end;
finally
tslist.Free;
end;
asheet.paste;
excel.quit;
messagebox(application.Handle,'0k!','system',mb_iconinformation or mb_ok);
end;
请各位大虾帮忙。。。。。。
Function TForm1.ToExcel():boolean;
var
i : integer;
tslist:TStringList;
s : string;
aSheet,excel : Variant;
begin
result:=true;
Excel := CreateOleObject( 'Excel.Application' );
Excel.Visible:=true;
Excel.Workbooks.Add;
aSheet:=excel.Worksheets.Item[1];
tsList:=TStringList.Create;
try
try
with Query1do
begin
Open;
First;
While Not Eofdo
begin
s:='';
for i:=0 to FieldCount-1do
begin
s:=s+Fields.AsString+#9;
Application.ProcessMessages;
end;
tsList.Add(s);
next;
end;
close;
end;
clipboard.astext:= tslist.text;
except
result:=false;
end;
finally
tslist.Free;
end;
asheet.paste;
excel.quit;
messagebox(application.Handle,'0k!','system',mb_iconinformation or mb_ok);
end;
请各位大虾帮忙。。。。。。