0
我正在嘗試創建一個csv並將其下載到瀏覽器。從我能找到的東西來看,在Symfony2中幾乎有這個ZERO文檔。Symfony2創建並下載CSV
這裏是我的代碼:
// Pass in all of the variables that will make up the pdf...
$response = $this->renderView('WICPurchaseOrderBundle:PurchaseOrder:csv.html.twig', array("data"=>$data
)
);
$response->headers->set('Content-Type', 'text/csv'); // This is line 929 in the error.
$response->headers->set('Content-Disposition', 'attachment; filename="teams.csv"');
return $response;
這是錯誤我得到:
Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/symfonydev/src/WIC/PurchaseOrderBundle/Controller/PurchaseOrderController.php line 929
任何有CSV在Symfony2中的經驗,並能幫助我嗎?謝謝!
哇,我不能相信這是這麼簡單。非常感謝你的幫助! – LargeTuna