Re: note 24724 added to ref.com
| From: | Jesus M. Castagnetto | Date: | Tue, 27 Aug 2002 22:31:15 +0000 |
| Subject: | Re: note 24724 added to ref.com | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-35813@lists.php.net to get a copy of this message | ||
Have you submitted a bug report to bugs.php.net? If
not, do it so the php-dev group is aware of it. It
will be better if you can come up with a patch to the
C code, as not many in the php-dev use Windows for
development. It will also help to contact the person
who wrote the COM extension.
Your note will be kept in the manual for now. Let us
know when this is resolved to remove it.
--- dwt@myrealbox.com wrote:
> When first writing applications instancing COM
> objects I always faced the problem of the instanced
> program not terminating correctly although
> everything else worked fine. In fact the process had
> to be killed manually by using the task manager.
> When experimenting a bit I was able to isolate the
> cause for this peculiar behaviour to be illustrated
> by the sample code below:
>
> <?php
>
> //Accessing arrays by retrieving elements via
> function ArrayName(Index) works, but certainly is
> neither efficient nor good style
> $excel=new COM("Excel.Application");
> $excel->sheetsinnewworkbook=1;
> $excel->Workbooks->Add();
>
> $book=$excel->Workbooks(1);
> $sheet=$book->Worksheets(1);
>
> $sheet->Name="Debug-Test";
> $book->saveas("C:\\debug.xls");
>
> $book->Close(false);
> unset($sheet);
> unset($book);
> $excel->Workbooks->Close();
> $excel->Quit();
> unset($excel);
>
> //Accessing arrays as usual (using the [] operator)
> works, buts leads to the application not being able
> to terminate by itself
> $excel=new COM("Excel.Application");
> $excel->sheetsinnewworkbook=1;
> $excel->Workbooks->Add();
>
>
$excel->Workbooks[1]->Worksheets[1]->Name="Debug-Test";
> $excel->Workbooks[1]->saveas("C:\\debug.xls");
>
> $excel->Workbooks[1]->Close(false);
> $excel->Workbooks->Close();
> $excel->Quit();
> unset($excel);
>
> ?>
>
> The sample code performs the same action twice and
> each time the file is properly created. Yet for some
> mysterious reason the instanced excel process won't
> terminate once you've accessed an array the way most
> programmers (especially those who do a lot of oop in
> c++) do! Therefore until the PHP developers become
> aware of this problem we'll have to use the
> inefficient coding style illustrated in the first
> example.
> --
> http://www.php.net/manual/en/ref.com.php
>
http://master.php.net/manage/user-notes.php?action=edit+24724
>
http://master.php.net/manage/user-notes.php?action=delete+24724
>
http://master.php.net/manage/user-notes.php?action=reject+24724
>
>
> --
> PHP Notes Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
=====
--- Jesus M. Castagnetto <jmcastagnetto@php.net>
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com