Opening Word document in read mode using php?

前端 未结 1 1032
孤街浪徒
孤街浪徒 2021-01-14 09:16

I want to read a Word document in a browser using PHP. I have been trying for more than two hours, but I cant get it to work. Can someone help me do this?

1条回答
  •  孤街浪徒
    2021-01-14 09:29

    As your not too detailed in your question on your specific requirements or server setup, this will get you started & also answers the question.

    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)
    ?>
    

    0 讨论(0)
提交回复
热议问题