闂備浇銆€閸嬫捇鏌熼婊冾暭妞ゃ儻鎷� (0) +1 闂佽崵濮嶅鍡楊伓 (0) +1 闂傚倸饪存禍鐑藉箯閿燂拷 (0) +1
闂備浇銆€閸嬫捇鏌熼婊冾暭妞ゃ儲鍨块弻鐔衡偓娑櫭慨鍥р攽椤曞棙瀚�闂備礁鎼悮顐﹀磿閸愯鑰块柛娑欐綑缂佲晠鏌熼婊冾暭妞ゃ儻鎷�>>

正在阅读:PHP脚本的8个技巧(6)PHP和COMPHP脚本的8个技巧(6)PHP和COM

2004-02-14 09:33 出处:奥索网 作者:netant 责任编辑:pjl
PHP和COM   如果你是一名冒险份子,而且你正在使用CGI、ISAPI或Apache模块版本的Windows系统上运行着PHP,那么你也可以获得系统的COM功能。现在,解释COM(微软的组件对象模型)的工作留给了微软和那些大部头的图书来完成。然而,知道点COM也没什么错,下面有一个普通的(没有双关语,针对很普通)代码小片断。 这代码小片断使用PHP在后台启动Microsoft Word、打开一个新文件、键入一些文本、保存该文件然后关闭应用程序: <? // 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..."; ?> 假设你正在运行一个内联网Web站点,该站点把数据存放在Microsoft SQL Server数据库内,你的用户需要Excel格式的数据。那么,你可以让PHP执行必要的SQL查询并且格式化输出结果,然后使用COM启动Excel,把数据传输给它,最后再把文件存储到用户的桌面系统内。

相关文章

302 Found

302 Found


Powered by Tengine
tengine
闂備礁缍婂ḿ褔顢栭崱妞绘敠闁逞屽墴閹鎷呴崨濠備淮濠碘槅鍋撻幏锟�闂備焦鎮堕崕鎶藉磻濞戙垹鏄ラ悘鐐板嫎娴滄粓鏌涢锝嗙闁告棑鎷�