这是我的代码:
<?php
require_once '../PHPWord-master/src/PhpWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Style\Font;
$texto = '<p>PRUEBA WORD <b>PRUEBA WORD </b>PRUEBA WORDPRUEBA WORD PRUEBA WORDPRUEBA WORDPRUEBA WORDPRUEBA WORDPRUEBA WORDPRUEBA WORD</p>';
$documento = new PhpWord();
$seccion = $documento->addSection();
$seccion->addText(
$prueba ,
array('name' => 'Tahoma', 'size' => 10)
);
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($documento, 'Word2007');
$xmlWriter->save('Documento01.docx');
header("Content-Disposition: attachment; filename='Documento01.docx'");
echo file_get_contents('Documento01.docx');
?>
生成.docx文件,但是当我打开它时会显示错误消息“此文件已损坏,无法打开”