delphi对Excel进行排序后,后台无法退出excel.exe进程!
如题
代码如下:
var
excelapp:Variant;
i,temp:integer;
key1: oleVariant ;
str:string;
begin
ExcelApp:=CreateOleObject( 'Excel.Application' );
ExcelApp.WorkBooks.Open('c:\1.xls');
ExcelApp.Visible:=true;
ExcelApp.DisplayAlerts:=false;
ExcelApp.worksheets[1].activate;
temp:=0;
for I := 1 to 200 do
begin
str:=ExcelApp.cells[i,1];
if str<>'' then
temp:=temp+1;
end;
ExcelApp.Range['a2:X14'].select;
ExcelApp.selection.Sort(Key1:=ExcelApp.range['h1']);
ExcelApp.ActiveWorkbook.Save;
ExcelApp.Quit;
end;