1 回答
TA贡献1813条经验 获得超2个赞
对于您需要渲染并分配给变量的视图:
$view_content = View::make('prints.events-view', ['events' => $events, 'logo' => $logo])->render();
然后通过这个库创建一个word文档并将内容附加到
// 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($view_content);
// Saving the document as HTML file...
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$file_name = 'event_calendar_' . '-' . now()->toDateString() . '.doc';
$objWriter->save(public_path($file_name));
然后文件的 URL 将是 url($file_name)
- 1 回答
- 0 关注
- 211 浏览
添加回答
举报