<? header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=test.xls"); echo "test1\t"; echo "test1\n\t"?>

解决方案 »

  1.   

    好象没有什么效果,这个只能出现本地机器的office的版本号码!
      

  2.   

    用com函数,调用客户端word
    <?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 ?>
      

  3.   

    com有问题,牛肉饭,你测试成功了???
      

  4.   

    我在本机上测试成功了,也就是说,服务器和客户端是同一台机器。我是学生,所以没办法远端测试:(
    所以我有点“想当然”的就认为是调用客户端的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")会有什么结果。大家试一试吧。
      

  5.   

    我感觉maxid 说的没错啊/我就用类似的方法生成了EXCEL文件,并且一直在用,没出过错
    <?       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