A PHP Error was encountered
Severity: Error
Message: Class 'PhpOffice\Common\Text' not found
Filename: Element/Text.php
Line Number: 139
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 = '
$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;
}
}
請幫助。
2017-08-30
woninana
+0
分享您的控制器代碼。 –
+0
@Tpojka編輯我的問題與控制器代碼 –
+0
我不知道'共同'和文檔鏈接是什麼被打破。但我明白你的主要問題是'PHPWord'。對? –