0
我想將數據庫數據導出到「CSV」並下載「CSV」文件,只要點擊一個按鈕。Symfony2如何將數據庫數據導出到csv
目前在「控制器」中,我從數據庫中獲取所有必要的數據,使用「存儲庫」來達到此目的。
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('SkerpInventoryBundle:InventoryMaster')->findAllIndex();
的$entities
將包含所有的數據,我想那導出到「CSV」。
在樹枝中我有一個用於下載「CSV」文件的按鈕。
以下是按鈕的樹枝代碼 -
<a href="{{ path('location') }}">Export as Excel</a>