Begin:
Copy 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 ');
}
registrantstocsvsuccess.php in Template:
Copy Code code 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/