我想通了這一點。退房的解決方案來閱讀Word文檔和HTML格式是:
$filename = "ACME.doc";
$word = new COM("word.application") or die ("Could not initialise MS Word object.");
$word->Documents->Open(realpath($filename));
$new_filename = substr($filename,0,-4) . ".html";
// the '2' parameter specifies saving in txt format
// the '6' parameter specifies saving in rtf format
// the '8' parameter specifies saving in html format
$word->Documents[1]->SaveAs("C:/a1/projects/---full path--- /".$new_filename,8);
$word->Documents[1]->Close(false);
$word->Quit();
//$word->Release();
$word = NULL;
unset($word);
$fh = fopen($new_filename, 'r');
$contents = fread($fh, filesize($new_filename));
echo $contents;
fclose($fh);
//unlink($new_filename);
夫婦的事情......有了「字符集= UTF-8」在我的PHP頁面的頂部被添加了一堆鑽石問題標記...我刪除了它,它完美的作品。
此外,SaveAs必須具有完整的路徑,至少在本地,我補充說,讓它工作。
再次感謝您的幫助。
這可能嗎? – alex 2011-03-17 02:45:03
我希望大聲笑...我發佈的代碼的作品,但它仍然沒有格式它的反正。 – 2011-03-17 02:47:31
您需要一些軟件來解析Word格式的文法並將其轉換爲HTML和CSS。 – alex 2011-03-17 02:49:59