标签:
1. 需要在APP服务器上安装Office
2. 可能需要创建文件夹:Desktop
C:\Windows\SysWOW64\config\systemprofile\Desktop
3. 可能需要设置权限 component service,中找到 “Microsoft Office ….”中的属性,设置相关的权限
4. 可能需要设置Apache服务的登录用户名及密码
function getRTFtext($rtfFileName) { $result=‘‘; if (!is_file($rtfFileName)) { throw new ErrorException("File not found."); } $rtfFileName = realpath($rtfFileName); // Connect to Word if (!class_exists(‘COM‘)) { throw new ErrorException(‘COM extension is not enabled.‘); } $word = new COM("word.application"); if (!$word) { throw new ErrorException(‘Unable to instantiate Word COM object.‘); } // Check the Word version. if ($word->Version < 12) { $word->Quit(); $word = null; throw new ErrorException(‘The version of Word is too old.‘); } // $word->visible = 1; try { // Documents.Open: http://msdn.microsoft.com/en-us/library/office/ff835182%28v=office.14%29.aspx //$word->Visible=true; $word->Documents->Open($rtfFileName, FALSE, TRUE); $result= $word->ActiveDocument->content->Text; $word->ActiveDocument->Close(FALSE); //echo ‘‘.$test; } catch (Exception $e) { $word->Quit(); $word = null; throw $e; } try { $word->Quit(); $word = null; } catch (Exception $e) { var_dump($e); } return $result; }
标签:
原文地址:http://www.cnblogs.com/krisy/p/5456254.html