Start:
Copy codeThe Code is as follows:
Public function executeRegistrantsToCsv (){
$ Id = $ this-> getRequestParameter ('id ');
$ C = new Criteria ();
$ C-> add (RegistrantPeer: EVENT_ID, $ id );
$ C-> add (RegistrantPeer: STATUS, 1 );
$ This-> aObjReg = RegistrantPeer: doSelect ($ c );
$ This-> forward404Unless ($ this-> aObjReg );
$ This-> setlayout ('csv ');
$ This-> getResponse ()-> clearHttpHeaders ();
$ This-> getResponse ()-> setHttpHeader ('content-type', 'application/vnd. ms-excel ');
$ This-> getResponse ()-> setHttpHeader ('content-disposition', 'attachment; filename = registrants_report_event _ '. $ id. '.csv ');
}
In the template registrantsToCsvSuccess. php:
Copy codeThe Code is as follows:
Title, Name, Email, Phone, Organisation, State, City, Country, Login Date, IpAddress
<? Foreach ($ aObjReg as $ r):?>
<? = $ R-> getTitle ()?>, <? = $ R-> getName ()?>, <? = $ R-> getEmail ()?>, <? = $ R-> getPhone ()?>, <? = $ R-> getOrganisation ()?>, <? = $ R-> getState ()?>, <? = $ R-> getCity ()?>, <? = $ R-> getCountry ()?>, <? = $ R-> getLoginDate ()?>, <? = $ R-> getIpAddress ()?>,
<? Endforeach?>
In the templates/csv. php:
<? Php echo $ sf_data-> getRaw ('sf _ content')?>
From: http://blog.baddog.net.au/sonius/steve-sonius/how-to-export-data-as-a-csv-file-in-symfony/
If it doesn't work, try this: http://blog.baddog.net.au/sonius/steve-sonius/how-to-export-data-as-an-xls-or-csv-file-from-the-admin-generator-in-symfony-1-4/