note 37108 deleted from ref.com by danbrown
| From: | danbrown@php.net | Date: | Mon, 21 Dec 2009 17:13:51 +0000 |
| Subject: | note 37108 deleted from ref.com by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164225@lists.php.net to get a copy of this message | ||
Note Submitter: feelingflash at hotmail dot com
----
PROBLEM QUITTING MICROSOFT EXCEL
I have been trying to solve the problem of terminating the excel process when using the COM
functionality. I found a few 'supposed fixes' including not using arrays etc but none of
them seemed to work. Example:
$excel->application->Quit();
$excel->Quit();
None of these variants properly quit the process - ONLY the visible application. Several hours of
using your code would leave thousands of excel processes running invisibly in the background and
eating all your ram very quickly.
As I was developing on a solution designed to work on clients running windows, my solution was to
install microsofts 'kill.exe' into the windows directory and then run it using:
shell_exec("kill excel.exe");
One problem is because kill.exe is an add on utility, some clients running windows will not have it.
The solution is then to use file_exists(filename) to detect for the file and then if not present,
let the user download it. Example:
$killApp = "C:\WINDOWS\KILL.EXE";
if (file_exists($killApp)) {
# continue
} else {
# show message and link to kill.exe download
}