3
我想在瀏覽器中使用PHP讀取Word文檔。 我一直在嘗試兩個多小時,但我不能得到它的工作。 有人可以幫我做這個嗎?使用php在讀取模式下打開Word文檔?
我想在瀏覽器中使用PHP讀取Word文檔。 我一直在嘗試兩個多小時,但我不能得到它的工作。 有人可以幫我做這個嗎?使用php在讀取模式下打開Word文檔?
由於您對您的具體要求或服務器設置的問題不太詳細,這會讓您開始&也回答這個問題。
<?php
$DocumentPath="C:/xampp/htdocs/test.doc";
//Create an instance of the Word application
$word = new COM("word.application") or die("Unable to instantiate application object");
//Creating an instance of the Word Document object
$wordDocument = new COM("word.document") or die("Unable to instantiate document object");
$word->Visible = 0;
//Open up an empty document
$wordDocument = $word->Documents->Open($DocumentPath);
//Create the filename for the HTML version
$HTMLPath = substr_replace($DocumentPath, 'html', -3, 3);
//Save the document as HTML
$wordDocument->SaveAs($HTMLPath, 3);
// clean up
$wordDocument = null;
$word->Quit();
$word = null;
// read the newly-created document
readfile($HTMLPath);
//delete the file
unlink($HTMLPath)
?>
Word文檔在您的服務器上正確嗎? –
這是一個* nix或Windows環境? – Shoan