User Contributed Notes COM support functions for Windows |
|
20-Dec-2000 06:45 |
|
As Jason ([email protected]) as demonstrated in his code example, there is a
PHP database wrapper class library that can connect to ADO available
called ADODB.
It is available from and
supports many databases both on Windows and Linux.
Modelled after ADO, so it should be easy for Windows programmers to learn.
|
|
31-Mar-2001 11:37 |
|
I thought i'd share with those of you unfamiliar with one of the cool
things
about developing php on win32 systems..
This is a good article, but i don't think the author hit the nail on the
head showing how useful this can be.
Now, checkout this article:
Notice how he describes 1) how to build a com object & 2) how to call
and
use the com object from ASP.
In php, this is how you would call the same object:
<?
$instance = new COM("Checkyear.LeapYear");
$isleapyear = $instance->IsLeapYear($year);
$instance->close();
if($isleapyear) {
echo "The <b>$year</b> is a leap year";
}
else {
echo "The <b>$year</b> is not a leap year";
}
?>
I hope this helps someone.. you can contact me at [email protected] if
you would like to discuss this further.
|
|
28-Feb-2002 03:11 |
|
now in PHP >=4.0.6
programming in window can use the
ADO through the COM like this:
$dbconn=new COM ("ADODB.Connection") or die ("connection
create fail");
$dbconn->Open("Provider=sqloledb;Data Source=ndht;Initial
Catalog=printers;User Id=printers;Password=printers;");
$rec=new COM("ADODB.Recordset") or die ("create Recordset
error");
while (!$rec->EOF)
{
echo $rec->fields["fieldname"]->value." ";
$rec->movenext();
}
$rec->close();
$dbconn->close();
but there's still a little question of working with the image field of
mssql server.
|
|
07-Mar-2002 06:59 |
|
I thought this excel chart example could be useful.
Note the use of Excel.application vs Excel.sheet.
<pre>
<?php
print "Hi";
#Instantiate the spreadsheet component.
# $ex = new COM("Excel.sheet") or Die ("Did not
connect");
$exapp = new COM("Excel.application") or Die ("Did not
connect");
#Get the application name and version
print "Application name:{$ex->Application->value} " ;
print "Loaded version: {$ex->Application->version} ";
$wkb=$exapp->Workbooks->add();
#$wkb = $ex->Application->ActiveWorkbook or Die ("Did not open
workbook");
print "we opened workbook ";
$ex->Application->Visible = 1; #Make Excel visible.
print "we made excell visible ";
$sheets = $wkb->Worksheets(1); #Select the sheet
print "selected a sheet ";
$sheets->activate; #Activate it
print "activated sheet ";
#This is a new sheet
$sheets2 = $wkb->Worksheets->add(); #Add a sheet
print "added a new sheet ";
$sheets2->activate; #Activate it
print "activated sheet ";
$sheets2->name="Report Second page";
$sheets->name="Report First page";
print "We set a name to the sheet: $sheets->name ";
# fills a columns
$maxi=20;
for ($i=1;$i<$maxi;$i++) {
$cell = $sheets->Cells($i,5) ; #Select the cell (Row Column number)
$cell->activate; #Activate the cell
$cell->value = $i*$i; #Change it to 15000
}
$ch = $sheets->chartobjects->add(50, 40, 400, 100); # make a
chartobject
$chartje = $ch->chart; # place a chart in the chart object
$chartje->activate; #activate chartobject
$chartje->ChartType=63;
$selected = $sheets->range("E1:E$maxi"); # set the data the
chart uses
$chartje->setsourcedata($selected); # set the data the chart uses
print "set the data the chart uses ";
$file_name="D:/apache/Apache/htdocs/alm/tmp/final14.xls";
if (file_exists($file_name)) {unlink($file_name);}
#$ex->Application->ActiveWorkbook->SaveAs($file_name); # saves
sheet as final.xls
$wkb->SaveAs($file_name); # saves sheet as final.xls
print "saved ";
#$ex->Application->ActiveWorkbook->Close("False");
$exapp->Quit();
unset($exapp);
?>
</pre>
Alex Madon
|
|
02-Apr-2002 10:01 |
|
An easy way to send e-mail using your default Outlook account:
<?
$objApp = new COM("Outlook.Application");
$myItem = $objApp->CreateItem(olMailItem);
$a=$myItem->Recipients->Add("[email protected]");
$myItem->Subject="Subject";
$myItem->Body="This is a Body Section now.....!";
$myItem->Display();
$myItem->Send();
?>
|
|
19-Apr-2002 10:34 |
|
an easy way to convert your file from .doc to .html
// starting word
$word = new COM("word.application") or die("Unable to
instanciate Word");
// if you want see thw World interface the value must be '1' else '0'
$word->Visible = 1;
//doc file location
$word->Documents->Open("E:\\first.doc");
//html file location '8' mean HTML format
$word->Documents[1]->SaveAs("E:\\test_doc.html",8);
//closing word
$word->Quit();
//free the object from the memory
$word->Release();
$word = null;
|
|
03-Jun-2002 05:31 |
|
Hi, I'm Frank, i have problem with function COM, the sentence that I use
is...
$app=new COM("word.application");
return a error that is...
Warning: Unable to obtain IDispatch interface for CLSID
{000209FF-0000-0000-C000-000000000046}: Se ha denegado el acceso.
I need help...
in the file PHP.INI have...
com.allow_dcom = true
|
|
03-Jun-2002 05:41 |
|
Hi... I'm Frank (chile)
I have installing the PHP 4.2.1 and I have the next problem, at utilized
the library php_oci8.dll return the next error...
PHP Warning: Unable to load dynamic library
'C:\php\extensions/php_oci8.dll' - No se ha encontrado el proceso
especificado
I has update the file php_oci8.dll, but equality return the error.
before I have the php 4.0.4 and I not have the problem... also with the
new version give me problem with the function COM()
|
|
18-Jun-2002 05:17 |
|
reinstall the previous php version...
|
|
28-Jun-2002 04:48 |
|
Complementing Alex's Excell Example, let's print the SpreadSheet to a PDF
file using Acrobat Distiller:
$null = new VARIANT("null", VT_NULL);
$wkb->PrintOut($null->value, $null->value, $null->value,
$null->value, "Acrobat Distiller");
There you go!!!
|
|
09-Jul-2002 05:44 |
|
Apparently you can only use COM objects which have the Count and Item
methods.
|
|
sangapum at hotmail
18-Jul-2002 03:50 |
|
MS Outlook & PHP
This was posted by someone, earlier on in the page:
=============================
An easy way to send e-mail using your default Outlook account:
<?
$objApp = new COM("Outlook.Application");
$myItem = $objApp->CreateItem(olMailItem);
$a=$myItem->Recipients->Add("[email protected]");
$myItem->Subject="Subject";
$myItem->Body="This is a Body Section now.....!";
$myItem->Display();
$myItem->Send();
?>
==========================
I'm running Win NT 4, latest version of PHP on my Apache server (latest
ver.)
I'm not able to get this to work. I tried opening up a word application
and it worked flawlessly (thru a different example on the page).
But outlook is having problems. Although the first two lines "$objApp
= new COM("Outlook.Application"); $myItem =
$objApp->CreateItem(olMailItem);" seem to work okay because it is
able to return a version number when I echo it. But anything after that
has trouble. I'm running outlook ver 9.
Has anyone else run into any similar situations? My goal is to open
outlook to access some email-groups and send out a customized email.
Basically I need to grab those email addresses in the groups
(distribution-lists).
Help!
|
|
|