View Full Version : using PHP's COM extension

10-24-2003, 05:23 PM
Hi everyone,

I have this code:
$excel = new COM("Excel.Application" ) or Die ("Did not connect" );
$excel->Visible = 1;
$wkbs = $excel->Workbooks->Add();
$sheet =$wkbk->ActiveSheet;
$excel->application->ActiveWorkbook->Close("False" );
unset ($excel);

it runs and an instance of excel.exe is created, but I don't see the app. I thought the visible property showed like it would if you would manually start excel.

I have also tried using:
$excel->application->visible = 1;
No joy still

Please help someone. I am working with PHP4/Apache 1.3 on XP


10-25-2003, 05:40 AM
Hi , COM is useful , but when used as part of a PHP web-based script the idea is not really to show the interface (many COM applications dont even have an interface) .

Its more for say , passing data to an instance of Word or Excel and then get Word or Excel to save/manipulate that data in is native format, or whatever functionality your COM object provides.

If you want to actually see the thing you need to drop out of the webserver , eg , save your script as (eg call it whaever you want ) comtest.php.sh

then open notepad and save the following but with your own paths to PHP and the script... as comtest.bat (save it anywhere)

c:\phpdev\php\php-4.3.3\php.exe -f e:\phpdev\www\comtest.php.sh

then double click the .bat file and you should see excel and that stupid paperclip (actually I think the paperclip does not work here unless invoked but I dunno for sure cos I terminated mine ages ago ;))