Tutorials to .com

Tutorials to .com » Php » Others » PHP script of 8 skills (6) PHP and COM

PHP script of 8 skills (6) PHP and COM

Print View , by: iSee ,Total views: 8 ,Word Count: 410 ,Date: Mon, 20 Apr 2009 Time: 4:08 AM

If you are an adventure elements, and you are using CGI, ISAPI or Apache module version of the Windows system running PHP, so you can get the COM systems function. Now, the explanation of COM (Microsoft's Component Object Model) of the work and those who left Microsoft to complete the lengthy book. However, COM also know that no wrong point, following a common (no pun, for the very common) code in small pieces.

This small fragment to use php code in the background to start Microsoft Word, open a new document, type some text, save the file and then close the application:

/ / Create a reference to a new COM component (Word)
$ word = new COM ( "word.application") or die ( "Can't start Word!");

/ / Print the version of Word that's now in use
echo "Loading Word, v. ($ word-> Version) <br>";

/ / Set the visibility of the application to 0 (false)
/ / To open the application in the forefront, use 1 (true)
$ word-> Visible = 0;

/ / Create a new document in Word
$ word-> Documents-> Add ();

/ / Add text to the new document
$ word-> Selection-> TypeText ( "Testing 1-2-3 ...");

/ / save the document in the Windows temp directory
$ word-> Documents [1] -> SaveAs ( "/ Windows / temp / comtest.doc");

/ / Close the connection to the COM component
$ word-> Quit ();

/ / Print another message to the screen
echo "Check for the file ...";

Suppose you are running an Intranet Web site, the site data stored in Microsoft SQL Server database, your users will need Excel format. In that case, you can perform the necessary PHP and SQL query output format, and then use COM to start Excel, the data to it, then the final document to the user's desktop storage systems.

php other Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.