Reinstalled my server 3 times to get the latest version of php and that still hasn't fixed my problem 🙁
Weeell, I am using the PHP COM feature to "do some cool things" with excel, and for some reason I can't get past some simple experimentation because I get this error:
Warning: Invoke() failed: Type mismatch. Argument: 2 in c:\phpdev\www\sdweekly.php on line 25
and for another part:
Warning: PropPut() failed: Exception occurred. Source: Microsoft Excel Description: Unable to set the HorizontalAlignment property of the Range class in c:\phpdev\www\sdweekly.php on line 28
Well, here's the code with error lines marked:
<?php
// create an object instance
$excel = new COM("Excel.Application") or die("Excel could not be
started");
// pop open the Excel application
$excel->Visible = 1;
// turn off alerts
$excel->DisplayAlerts = 0;
// open a workbook
$excel->Workbooks->Open("C:\Documents and Settings\Family\My Documents\SD WEEKLY#.xls");
$sheet = $excel->Activesheet->Name;
print "$sheet<br>";
$cell = $excel->Activesheet->Cells->Item(18, 15);
$cell->value = "RANK";
$cell = $excel->Activesheet->Cells->Item(18, 16);
$cell->value = "DOLLAR AMOUNT";
$cell = $excel->Activesheet->Range("O18:Q18");
$cell->Interior->ColorIndex = 15;
$border = $cell->Borders(xlEdgeBottom); //error
$border->LineStyle = "xlContinuous";
$cell->font->Bold = True;
$cell->HorizontalAlignment=xlRight; // error
$excel = null;
?>
I am 100% sure I am using the right objectname's and for those of you who don't believe me, you can check yourself if you have excel installed at:
c:\Program Files\Microsoft Office\Office10\1033\VBAXL10.CHM"
All the class info i have discovered in there.
Please can someone help me with this problem - I need to do my homework! 😉