在Controller的功能中(使用Symfony4),我构建了一个表格PhpSpreadSheet,然后将其发送给用户并保存了(有效)。之后,我返回了重定向。看来这种回报将无法实现!它似乎在“ $ writer-> save($ fichier);”之后中断了。并直接跳至表单的提交
$form=$formBuilder->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
//stuff....
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xls($spreadsheet);
$writer->save('php://output');
$adr='./Frais_comite/';
$fichier=$adr.$nomfic;
$writer->save($fichier);
return $this->redirectToroute('comite_envoi_frais', ['fichier' => $fichier] );
}
$content = $this->get('templating')->render('comite/frais.html.twig', 'form'=>$form->createView()]);
return new Response($content);
感谢您的帮助!