PHPWord-找不到类别'PhpOffice \ PhpWord \ PhpWord'

遇到错误,找不到“ PhpOffice \ PhpWord \ PhpWord”类 我的composer.json “ php”:“> = 7.0.0”,         “ abrigham / laravel-email-exceptions”:“ ^ 1.3”,         “ barryvdh / laravel-debugbar”:“ ^ 3.2”,         “ barryvdh / laravel-dompdf”:“ ^ 0.8.4”,         “ ckfinder / ckfinder-laravel-package”:“ ^ 3.5”,         “ karlomikus / theme”:“ ^ 1.0”,         “ laravel / framework”:“ 5.5。”,         “ laravel / socialite”:“ ^ 3.0”,         “ laravel / tinker”:“〜1.0”,         “ laravelcollective / html”:“ ^ 5.4.0”,         “ leafo / scssphp”:“ ^ 0.7.7”,         “ maatwebsite / excel”:“〜2.1.0”,         “ nicolaslopezj / searchable”:“ 1。”,         “ niklasravnsborg / laravel-pdf”:“ ^ 3.1”,         “ phpoffice / phpword”:“ ^ 0.17.0”,         “ shivella / laravel-bitly”:“ ^ 1.0”,         “ simplesoftwareio / simple-qrcode”:“ ^ 2.0”,         “ sofa / laravel-global-scope”:“ ^ 0.2.0”,         “ yajra / laravel-datatables”:“ ^ 1.0”,         “ yajra / laravel-datatables-oracle”:“ ^ 8.0”,         “ zendframework / zend-escaper”:“ ^ 2.6”,         “ zendframework / zend-stdlib”:“ ^ 3.2”

评论
  • 一脸苍白i
    一脸苍白i 回复

    maybe this answer can help you

    // Creating the new document...
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    
    /* Note: any element you append to a document must reside inside of a Section. */
    
     // Adding an empty Section to the document...
    $section = $phpWord->addSection();
    
    // Adding Text element to the Section having font styled by default...
    $section->addText(
        htmlspecialchars(
            '"Learn from yesterday, live for today, hope for tomorrow. '
                . 'The important thing is not to stop questioning." '
                . '(Albert Einstein)'
        )
    );
    
    // Saving the document as HTML file...
    $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
    $objWriter->save('helloWorld.html');
    
    
      [1]: https://stackoverflow.com/a/31627457/1873569