小编Alb*_*bee的帖子

symfony将html.twig导出到csv

我正在尝试将树枝视图输出到csv中,但是我被卡住了,有人可以用详细的解决方案帮助我吗?和平

/**
 *  
 * @Route("/export", name="export_csv")
 */
public function exportAction() {

    $entity = new Invite();
    $form = $this->createForm(new ManifSearchType(), $entity);
    $request = $this->get('request');

    $em = $this->getDoctrine()->getManager();

    $view = $this->render('PrifProtocoleBundle:Invite:index.html.twig', array(
        'form' => $form->createView()));

    $handle = fopen('php://memory', 'r+');
    $header = array();

    fputcsv($handle, $view);

    rewind($handle);

    $content = stream_get_contents($handle);
    fclose($handle);

    return new Response($content, 200, array(
        'Content-Type' => 'application/force-download',
        'Content-Disposition' => 'attachment; filename="export.csv"'
    ));
} 
Run Code Online (Sandbox Code Playgroud)

错误信息:

Warning: fputcsv() expects parameter 2 to be array, object given in C:\wamp\www\protocole\src\Prif\ProtocoleBundle\Controller\InviteController.php line 56 
Run Code Online (Sandbox Code Playgroud)

php csv symfony

2
推荐指数
1
解决办法
6358
查看次数

标签 统计

csv ×1

php ×1

symfony ×1