<? header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=test.xls"); echo "test1\t"; echo "test1\n\t"?>
解决方案 »
- 求高手帮我看看代码
- asp转型PHP有什么好书推荐?
- php脚本无法获取指定的环境变量
- PHP 远程调试环境搭建求助
- 谁能给个必须用ob_start( ) 的例子
- 大家帮个忙,怎样在mysql数据库查询一个字段
- php+mysql+apache的通用安装整合方法(越详细越好)
- 我怎么样设置服务器让它可以让浏览器可以浏览包含frameset的页面呢? 急救!!高分酬谢!!
- 在javascript中怎么接收form表格提交的数据?
- 淘宝卖家API如taobao.logistics.orders.get,如何应用到买家?
- 我该用用iis+asp还是apache+php呢?
- 我的mysql刚装,密码为空,怎么改呢?
<?php#*********************************************************
# This example, slightly modified from the Zend site,
# will open an instance of word with a new
# document with the name "Useless test.doc" and the line:
# "This is a test2..." typed inside.
#*********************************************************#Instantiate the Word component.初始化word组件$word = new COM("word.application") or die("Unable to instantiate Word"); #Get and print its version显示word版本 print "Loaded Word, version {$word->Version}<BR>"; #Another way to get the version using com_get另一个获取版本的方法$testversion = com_get($word->application,version);print "Version using Com_get(): $testversion <BR>";#Make it visible in a window使word窗口可见$word->Visible = 1; #Open a new document创建新文档 $word->Documents->Add(); #Write something写入数据$word->Selection->TypeText("This is a test..."); #Now save the document保存文档$word->Documents[1]->SaveAs("Useless test.doc"); #Comment next line if you want to see the word document,
#then close word manually退出word$word->Quit();
#Comment if you want to see the word document, then close ?>
所以我有点“想当然”的就认为是调用客户端的word了。不知大家对此有什么看法?
但是根据php手册上的说法,string COM::COM ( string module_name [, string server_name [, int codepage]])
COM class constructor. Parameters:
module_name
name or class-id of the requested component. server_name
name of the DCOM server from which the component should be fetched. If NULL, localhost is assumed. To allow DCOM com.allow_dcom has to be set to TRUE in php.ini. codepage
specifies the codepage that is used to convert php-strings to unicode-strings and vice versa. Possible values are CP_ACP, CP_MACCP, CP_OEMCP, CP_SYMBOL, CP_THREAD_ACP, CP_UTF7 and CP_UTF8. 注意server_name这个参数,说明中有这样的一句:“If NULL, localhost is assumed”,这说明,是可以调用远端的com对象的,那么应该也可以调用远端的word对象,不知道把这个参数传入getenv("REMOTE_ADDR")会有什么结果。大家试一试吧。
<? header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=test.xls"); echo "test1 \t"; echo "test2 \t\n"; echo "test1 \t"; echo "test2 \t\n"; echo "test1 \t"; echo "test2 \t\n";
?>而关于COM组件的调用,你可以看
http://www.phpbuilder.com/columns/alain20001003.php3