我想通了。查看阅读 Word Doc 并将其格式化为 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);
有几件事...在我的 PHP 页面顶部添加“charset=UTF-8”会添加一堆带问号的菱形...我删除了它,它运行良好。
此外,SaveAs 必须具有完整路径,至少在本地,我添加了它以使其工作。
再次感谢您的帮助。