Home arrow PHP arrow Page 2 - PHP and COM

Striving To Excel - PHP

You've already seen how PHP can be used to interface with Java components and JavaBeans. But here's something you didn't know - PHP can (shock shock! horror horror!) even be used to interface with Microsoft COM objects on the Windows platform. Will this be a happy marriage? Read on to find out.

TABLE OF CONTENTS:
  1. PHP and COM
  2. Striving To Excel
  3. The Number Game
  4. Export Potential
  5. Keeping It Simple
  6. Access-ing The Web
  7. All For One, And One For All
  8. New Coins For Old
  9. Link Zone
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 15
April 23, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Since COM is a Microsoft invention, it won't surprise you to hear that PHP's COM extension is only available for the Windows version of PHP. If you're using *NIX - well, you're outta luck. Shut down your browser and read a book instead.

If you're still interested, though, pop open your favourite editor and create a PHP script containing the following lines of code (this example assumes that you have a properly-installed copy of Microsoft Excel on your system):

<?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; // add a workbook $excel->Workbooks->Add(); // save $excel->Workbooks[1]->SaveAs("C:\\Inventory.xls"); // close the application $excel->Quit(); $excel = null; ?>
Now, when you run this script through your Web browser, the following things should happen very fast:

1. Microsoft Excel will start up automatically.

2. A new workbook will be added.

3. The workbook will be automatically saved as "C:\Inventory.xls"

4. Microsoft Excel will automatically shut itself down.

Wondering how this happened? Keep reading!

 
 
>>> More PHP Articles          >>> More By Harish Kamath, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: