我正在使用ckeditor
创建一个博客,并使用wordformate
在PHPWORD
中下载该博客。
但是当我打开下载word doc时,它没有打开,并给出了XML解析错误
我正在LARAVEL
上尝试
public function createWordDocuments( Request $request ,$id)
{
$data= Templete::where('id',$id)->first();
$wordTest= new \PhpOffice\PhpWord\PhpWord();
$newSection= $wordTest->addSection();
$wordText =json_decode($data['word']) ;
//echo $wordText;exit;
$newSection->addText($wordText);
\PhpOffice\PhpWord\Shared\Html::addHtml($newSection, $wordText , false, false);
$objectWriter = \PhpOffice\PhpWord\IOFactory::createWriter($wordTest,'Word2007');
try
{
ob_start();
$objectWriter->save(storage_path('TestWordFile.docx'));
ob_get_clean();
}
catch(Exception $e) {
}
return response()->download(storage_path('TestWordFile.docx'));
session()->flash('message','file download ');
return redirect()->to('/text');
}
我要在我下载的word文件中的ckediter工具中添加文本样式。