小
小任
Unregistered / Unconfirmed
GUEST, unregistred user!
在delphi中向excel导数,excelapp.open;导完以后excelapp.quit;但进程中的excel怎么也去不掉。
请大家帮忙。..
代码如下:
ExcelApp.Connect;//
ExcelApp.Visible[0]:=True;
// 打开已有的excel文件'e:/book1.xls'
excelworkbook1.ConnectTo(excelapp.Workbooks.Open('e:/book1.xls',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,0));
excelworkSheet1.ConnectTo(excelworkBook1.Sheets['table1'] as _WorkSheet);
z:=wwtable1.RecordCount;
wwtable1.First;
excelworkSheet1.Cells.Item[1, 1] := 'A';
excelworkSheet1.Cells.Item[1, 2] := 'B';
for i:=2 to z do
begin
excelworkSheet1.Cells.Item[i, 1] := wwtable1.fieldbyname('A').asstring;
excelworkSheet1.Cells.Item[i, 2] := wwtable1.fieldbyname('B').asstring;
wwtable1.next;
next;
end;
///退出
try
// excelapp.Visible[0]:=true;
//excelapp.SaveWorkspace;
//excelapp.Save('e:/book1.xls');
excelApp.Disconnect;
excelworkbook1.disconnect;
excelworksheet1.disconnect;
excelApp.Quit;
请大家帮忙。..
代码如下:
ExcelApp.Connect;//
ExcelApp.Visible[0]:=True;
// 打开已有的excel文件'e:/book1.xls'
excelworkbook1.ConnectTo(excelapp.Workbooks.Open('e:/book1.xls',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,0));
excelworkSheet1.ConnectTo(excelworkBook1.Sheets['table1'] as _WorkSheet);
z:=wwtable1.RecordCount;
wwtable1.First;
excelworkSheet1.Cells.Item[1, 1] := 'A';
excelworkSheet1.Cells.Item[1, 2] := 'B';
for i:=2 to z do
begin
excelworkSheet1.Cells.Item[i, 1] := wwtable1.fieldbyname('A').asstring;
excelworkSheet1.Cells.Item[i, 2] := wwtable1.fieldbyname('B').asstring;
wwtable1.next;
next;
end;
///退出
try
// excelapp.Visible[0]:=true;
//excelapp.SaveWorkspace;
//excelapp.Save('e:/book1.xls');
excelApp.Disconnect;
excelworkbook1.disconnect;
excelworksheet1.disconnect;
excelApp.Quit;