H
hj6
Unregistered / Unconfirmed
GUEST, unregistred user!
以下这段源代码是从数据库转换为Excel文件的,能正常的运行,但是怎样才能自动的把它
保存起来?并且能退出Excel?请大家帮我加上几条语句来实现它。谢谢!!!
procedure TForm1.Button1Click(Sender: TObject);
var
vExcel:OleVariant;
i,j:integer;
begin
vExcel:=CreateOleObject('Excel.application');
if checkbox1.Checked then
vExcel.visible:=true
else
vExcel.visible:=false;
vExcel.workbooks.add;
Table1.First ;
For i:=0 to Table1.FieldCount -1 do
vExcel.Cells.Item(1,i+1):=Table1.Fields.Displaylabel;
j:=2;
While not Table1.Eof do
begin
For i:=0 to Table1.FieldCount -1 do
begin
vExcel.Cells.Item(j,i+1):=Table1.Fields.AsString;
end;
j:=j+1;
Table1.Next ;
end;
end;
end.
保存起来?并且能退出Excel?请大家帮我加上几条语句来实现它。谢谢!!!
procedure TForm1.Button1Click(Sender: TObject);
var
vExcel:OleVariant;
i,j:integer;
begin
vExcel:=CreateOleObject('Excel.application');
if checkbox1.Checked then
vExcel.visible:=true
else
vExcel.visible:=false;
vExcel.workbooks.add;
Table1.First ;
For i:=0 to Table1.FieldCount -1 do
vExcel.Cells.Item(1,i+1):=Table1.Fields.Displaylabel;
j:=2;
While not Table1.Eof do
begin
For i:=0 to Table1.FieldCount -1 do
begin
vExcel.Cells.Item(j,i+1):=Table1.Fields.AsString;
end;
j:=j+1;
Table1.Next ;
end;
end;
end.