COM with PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gastonlm
Forum Commoner
Posts: 26
Joined: Tue May 07, 2002 10:19 am
Location: Buenos Aires, Argentina
Contact:

COM with PHP

Post by gastonlm »

I'm executing the following code and I recive an error. I don't know if I should have something installed in the server or in my machine. The code is the following and is for creating an excel file:

$exapp = new COM("excel.application") or Die ("Did not connect");
$exapp->Visible = true;
$workbook = $exapp->workbooks->Add();
$worksheet = $workbook->Worksheets(1);
$worksheet->activate;
$cell = $worksheet->Cells(1,1);
$cell->value = "Name";
$cell = $worksheet->Cells(1,2);
$cell->value = "Salary";
$cell = $worksheet->Cells(1,3);
$cell->value = "Time of Employment";
$worksheet->SaveAs("c:\\emp_reports-salary.xls");
$exapp->quit();

I recive the error:

Warning: Invalid ProgID, GUID string, or Moniker: Invalid syntax in C:\Web\admin\consultas\hoteles.php on line 331
Did not connect

Is the first time I'm trying to use a com object, so I don't know exactly how it works.
Can anybody help me??
Zmodem
Forum Commoner
Posts: 84
Joined: Thu Apr 18, 2002 3:59 pm

Post by Zmodem »

PHP does have COM support. But I'm sure it's pretty buggy. I believe it is also fairly new, and not very mature.

If you want to do a lot of stuff like that, you might try looking into ASP, which is better suited for complicated COM operations.

Just a suggestion....
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

use regedit.exe to take a look into your registry settings.
Search for 'Excel.Application' (should be 'HKEY_CLASSES_ROOT\Excel.Application'). If it isn't there you have to install Excel first ;)
If you find it change new COM("excel.application") to new COM("Excel.Application"). May be it's case sensitive.
gastonlm
Forum Commoner
Posts: 26
Joined: Tue May 07, 2002 10:19 am
Location: Buenos Aires, Argentina
Contact:

Post by gastonlm »

I've solved.
Post Reply