使用PHP在Landscape中创建Word文档

问题描述

| 我使用此代码创建MS Word文档。但是,我想在横向上进行制作。有人知道怎么做吗?谢谢
$fp = fopen(\'test.doc\',\'w+\');

$str = \"<html><body>Content</body></html>\";

fwrite($fp,$str);
fclose($fp);
    

解决方法

        据我所知,您的代码不起作用。 MS Word会生成二进制文件,因此您需要使用“ 1”对象。 这是一个例子:
<?php
$word = new COM(\"word.application\") or die (\"Could not initialise MS Word object.\");
$word->Documents->Open(realpath(\"Sample.doc\"));

// Extract content.
$content = (string) $word->ActiveDocument->Content;

echo $content;

$word->ActiveDocument->Close(false);

$word->Quit();
$word = null;
unset($word);
该示例从此处获取:http://www.developertutorials.com/tutorials/php/extracting-text-from-word-documents-via-php-and-com-81/