Begin:
Copy the Code code 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::d oselect ($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 the Code code as follows:
Title,name,email,phone,organisation,state,city,country,login date,ipaddress
GetTitle (), getName (), getemail ();, Getphone (),, getorganisation (),;, C6/>getstate (), getcity (), Getcountry (),, getlogindate (), getipaddress ()? ,
In the templates/csv.php:
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/
The above describes how symfony in the Symfony to export the data in the CSV file, including the symfony aspect of the content, I hope to be interested in PHP tutorial friends helpful.