xlsfile.quit;
xlsfile:= UnAssigned;
xlsfile:=null;
但怎么就没有释放excel文件呢?
3 个解决方案
#1
自己顶!
#2
帮你顶一下,我没有遇到这样的问题!
都能释放的!
try
finally
end;
怎么都能释放啊
都能释放的!
try
finally
end;
怎么都能释放啊
#3
XLApp := CreateOleObject('Excel.Application');
try
Sheet := XLApp.Workbooks[1].WorkSheets[1];
{...}
finally
if not VarIsEmpty(XLApp) then
begin
XLApp.DisplayAlerts := False;
XLApp.Quit;
XLAPP := Unassigned;
Sheet := Unassigned;
end;
end;
{注:是不是還用到其他変量?
例)var Sheet: OLEVariant; Sheet也要释放。}
try
Sheet := XLApp.Workbooks[1].WorkSheets[1];
{...}
finally
if not VarIsEmpty(XLApp) then
begin
XLApp.DisplayAlerts := False;
XLApp.Quit;
XLAPP := Unassigned;
Sheet := Unassigned;
end;
end;
{注:是不是還用到其他変量?
例)var Sheet: OLEVariant; Sheet也要释放。}
#1
自己顶!
#2
帮你顶一下,我没有遇到这样的问题!
都能释放的!
try
finally
end;
怎么都能释放啊
都能释放的!
try
finally
end;
怎么都能释放啊
#3
XLApp := CreateOleObject('Excel.Application');
try
Sheet := XLApp.Workbooks[1].WorkSheets[1];
{...}
finally
if not VarIsEmpty(XLApp) then
begin
XLApp.DisplayAlerts := False;
XLApp.Quit;
XLAPP := Unassigned;
Sheet := Unassigned;
end;
end;
{注:是不是還用到其他変量?
例)var Sheet: OLEVariant; Sheet也要释放。}
try
Sheet := XLApp.Workbooks[1].WorkSheets[1];
{...}
finally
if not VarIsEmpty(XLApp) then
begin
XLApp.DisplayAlerts := False;
XLApp.Quit;
XLAPP := Unassigned;
Sheet := Unassigned;
end;
end;
{注:是不是還用到其他変量?
例)var Sheet: OLEVariant; Sheet也要释放。}