0

彼らはプラグインを更新し、これに従っていくつかの共有クラスを置き換えました: https://github.com/PHPOffice/PHPWord/releases で、phpword をアップグレードすると、このエラーが発生しました。

A PHP Error was encountered

Severity: Error

Message: Class 'PhpOffice\Common\Text' not found

Filename: Element/Text.php

Line Number: 139





<?php
include_once(APPPATH."third_party/PHPWord/Autoloader.php");
if (!defined('BASEPATH'))
    exit('No direct script access allowed');


use PhpOffice\PhpWord\Autoloader;
use PhpOffice\PhpWord\Settings;
Autoloader::register();
Settings::loadConfig();


class Test extends CI_Controller {

    public function index() {
                $phpWord = new \PhpOffice\PhpWord\PhpWord();
                $phpWord->getCompatibility()->setOoxmlVersion(14);
                $phpWord->getCompatibility()->setOoxmlVersion(15);

                $section = $phpWord->addSection();
                $html = '<p><strong style="font-weight: 600;"This is a heading</strong></p>

                $filename = 'test.doc';

                \PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);
                $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
                $objWriter->save($filename);
                header('Content-Description: File Transfer');
                header('Content-Type: application/octet-stream');
                header('Content-Disposition: attachment; filename='.$filename);
                header('Content-Transfer-Encoding: binary');
                header('Expires: 0');
                header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                header('Pragma: public');
                header('Content-Length: ' . filesize($filename));
                flush();
                readfile($filename);
                unlink($filename); // deletes the temporary file
                exit;
        }
}

私はcomposerを使用していますが、共通の共有ライブラリを使用するかどうか疑問に思っています: https://github.com/PHPOffice/Common

助けてください。

4

1 に答える 1