第一步:安裝 PhpOffice\PhpWord
github地址:https://github.com/PHPOffice/PHPWord/
這裏僅支持composer安裝,
第二步:引入PhpWord
$path = './file.doc';//文件路徑
$path2 = './test_doc_html.html';//存放的路徑
include_once(ROOT_PATH.'vendor/autoload.php');//ROOT_PATH 這是項目根目錄 這個位置看你自己的
$phpWord = \PhpOffice\PhpWord\IOFactory::load($path);
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "HTML");
$xmlWriter->save($path2);