【发布时间】:2020-11-01 04:47:43
【问题描述】:
我想下载的时候可以自定义phpword中的文件名吗?
我希望文件采用导出行的prenoms。
我的代码:
public function edit (Stagiaire $stagiaire)
{
$id = $stagiaire ->id;
$desc1 = Stagiaire::find($id);
$my_template = new \PhpOffice\PhpWord\TemplateProcessor(public_path('templateStagiaire.docx'));
$my_template->setValue('id, $desc->id);
$my_template->setValue('prenoms, $desc->prenoms);
$my_template->setValue('nom, $desc->nom);
$filename = $stagiaire->prenoms;
try{
$my_template->saveAs(storage_path('templateStagiaire.docx'));
}catch (Réception $e){}
return response()->download(storage_path('".$filename.".docx));
}
需要帮助。 提前致谢。
【问题讨论】: