php读取word方法代码

分为 97 和2003版本word   2003版本可以用phpoffice处理   $phpWord = IOFactory::load($file); $xmlWriter = PhpOfficePhpWordIOFactory::createWriter($phpWord, "HTML"); $content = ''; foreach ($phpWord->getSections() as $section) { $writer = new PhpOfficePhpWordWriterHTMLElementContainer($xmlWriter, $section); $content .= $writer->write(); } 97版本需要只能在windows系统,需要安装com扩展 header("Content-type: text/html; charset=gbk"); $word = new COM("word.application") or die("Can't start Word!"); $word->Visible = 0; $word->Documents->Open($file); $content = $word->ActiveDocument->content->Text; $content = iconv("GB2312//IGNORE", "UTF-8", $content); $word->ActiveDocument->Close(); $word->Quit(); $item->doc_content = $content;