05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example 15-2. Completing and printing a Word invoice from <strong>PHP</strong> (continued)<br />

$word->visible = 1 ;<br />

$word->Documents->Open($invoice);<br />

// fill in fields<br />

$word->Application->Run("BkmkCustomer");<br />

$word->Selection->TypeText($customerinfo);<br />

$word->Application->Run("BkmkDelivery");<br />

$word->Selection->TypeText($deliverynum);<br />

$word->Application->Run("NextCell");<br />

$word->Selection->TypeText($shipdate);<br />

$word->Application->Run("NextCell");<br />

$word->Selection->TypeText($shipvia);<br />

$word->Application->Run("NextCell");<br />

$word->Selection->TypeText($orderdate);<br />

$word->Application->Run("NextCell");<br />

$word->Selection->TypeText($custnum);<br />

$word->Application->Run("NextCell");<br />

$word->Selection->TypeText($ordernum);<br />

$word->Application->Run("NextCell");<br />

$word->Application->Run("BkmkItem");<br />

$word->Selection->TypeText($item[1]);<br />

$word->Application->Run("NextCell");<br />

$word->Selection->TypeText($desc[1]);<br />

$word->Application->Run("NextCell");<br />

$word->Selection->TypeText($quantity[1]);<br />

$word->Application->Run("NextCell");<br />

$word->Selection->TypeText($cost[1]);<br />

$word->Application->Run("NextCell");<br />

$word->Selection->TypeText($subtot[1]);<br />

$word->Application->Run("BkmkTotal");<br />

$word->Selection->TypeText($total);<br />

// print it<br />

$word->Application->Run("invoiceprint");<br />

// wait to quit<br />

$word->Application->ActiveDocument->Saved=True;<br />

while($word->Application->BackgroundPrintingStatus>0){sleep (1);}<br />

// close the application and release the COM object<br />

$word->Quit( );<br />

$word->Release( );<br />

$word = null;<br />

?><br />

Reading and Writing Excel Files<br />

Controlling Excel is similar to controlling Word—research the APIs and use a combination<br />

of macros and COM. The hierarchy of objects is: the Application can have<br />

366 | Chapter 15: <strong>PHP</strong> on Windows<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!