用PHPWord读取* .docx

时间:2016-02-25 19:32:25

标签: php laravel phpword phpoffice

我在学校项目中使用Laravel,最近找到了PHPOffice库。我在文档中找到了一些例子,但我仍然无法理解如何应对Laravel。用composer安装它,现在我想读一些* .docx文件。有人知道如何实现这一目标吗?我用过这个

class ShareController extends Controller {
public function share($hashed_name){

    $ds = DIRECTORY_SEPARATOR;
    $userid = Auth::id();
    $name = basename(__FILE__, '.php');
    $source = storage_path('uploads\\'.$userid.'\\'.$onlyFilename.'_0.docx');
    echo date('H:i:s'), " Reading contents from `{$source}`", EOL;
    $phpWord = IOFactory::load($source);
    // Save file
    echo write($phpWord, basename(__FILE__, '.php'), $writers);
    if (!CLI) {
        include_once 'Sample_Footer.php';
    }

}

但是我得到了

Whoops, looks like something went wrong.
1/1 ErrorException in ShareController.php line 34: Use of undefined constant EOL - assumed 'EOL' 

0 个答案:

没有答案