选择显示字体大小

php脚本的8个技巧(6)php和com

php和com

  如果你是一名冒险份子,而且你正在使用cgi、isapi或apache模块版本的windows系统上运行着php,那么你也可以获得系统的com功能。现在,解释com(微软的组件对象模型)的工作留给了微软和那些大部头的图书来完成。 然而,知道点com也没什么错,下面有一个普通的(没有双关语,针对很普通)代码小片断。

这代码小片断使用php在后台启动microsoft word、打开一个新文件、键入一些文本、保存该文件然后关闭应用程序:

<?
// create a reference to a new com component (word)
&#36;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. {&#36;word->version}<br>";

// set the visibility of the application to 0 (false)
// to open the application in the forefront, use 1 (true)
&#36;word->visible = 0;

// create a new document in word
&#36;word->documents->add();

// add text to the new document
&#36;word->selection->typetext("testing 1-2-3...");

//save the document in the windows temp directory
&#36;word->documents[1]->saveas("/windows/temp/comtest.doc");

// close the connection to the com component
&#36;word->quit();

// print another message to the screen
echo "check for the file...";
?>

假设你正在运行一个内联网web站点,该站点把数据存放在microsoft sql server数据库内,你的用户需要excel格式的数据。那么,你可以让php执行必要的sql查询并且格式化输出结果,然后使用com启动excel,把数据传输给它,最后再把文件存储到用户的桌面系统内。


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons