我这样写,出现异常之后会有Excel进程驻留在内存:
Var
ExcelApp, ExcelBook, ExcelSheet: Variant;
begin
Try
ExcelApp := CreateOleObject('Excel.Application');
ExcelBook := ExcelApp.WorkBooks.Open(FXlsFile);
ExcelSheet := ExcelBook.Sheets.Item[1]; ........... ExcelBook.Close;
ExcelApp.Quit;
ExcelSheet:=Unassigned;
ExcelBook:=Unassigned;
ExcelApp:=Unassigned;
Except
On E:Exception do
begin
ExcelBook.Close;
ExcelApp.Quit;
ExcelSheet:=Unassigned;
ExcelBook:=Unassigned;
ExcelApp:=Unassigned;
end;
End;
Var
ExcelApp, ExcelBook, ExcelSheet: Variant;
begin
Try
ExcelApp := CreateOleObject('Excel.Application');
ExcelBook := ExcelApp.WorkBooks.Open(FXlsFile);
ExcelSheet := ExcelBook.Sheets.Item[1]; ........... ExcelBook.Close;
ExcelApp.Quit;
ExcelSheet:=Unassigned;
ExcelBook:=Unassigned;
ExcelApp:=Unassigned;
Except
On E:Exception do
begin
ExcelBook.Close;
ExcelApp.Quit;
ExcelSheet:=Unassigned;
ExcelBook:=Unassigned;
ExcelApp:=Unassigned;
end;
End;
解决方案 »
- 为什么点击“新建”按钮后,数据集状态不改变?
- 模糊查询的问题!~~
- 淘宝系统分析
- 为什么创建方捷方式的代码调试不成功(急)
- 提供Delphi 5的下载地址就给分!(要能下)
- 如何控制edit中的数字显示长度?
- 你好,我在剪切图片时将大的图片剪成小图片后,图片有些斑点,我是直接用Canvas的CopyRect方法来实现剪切的,调用前先将目的Image的大小直接
- 请问各位,开发一个系统时,是怎样定义用户的角色的?例如该用户对系统的访问功能..
- 如何用MEDIAPLAYER控件录音?
- 如何在DelPhi中进行模糊查询??(请教各位高手)
- com中获取Window Handle的问题
- 求一关于权限设置的代码,超级简单,谢谢各位了
....
except
ExcelBook.Close(false,emptyparam,emptyparam);
ExcelApp.Quit;
ExcelSheet:=Unassigned;
ExcelBook:=Unassigned;
ExcelApp:=Unassigned;
end;