Ladies & gentlemen, 
 
My client wants a .csv export with a simple list of entries, namely : the list 
of the web users who registered to his newsletter. 
I tried to add a ListCsvExport button in the backend and the appropriate method 
in the action, with no success. 
 
A simple template for tests : 
listCsvExportSuccess.php : 
<?php
echo implode("\t", $headers), "\n";
foreach($lines as $l) {
    echo implode("\t", $l, "\n");
}
?>

and the method : 
public function executeListCsvReport(sfWebRequest $request) {
     $response = $this->getResponse();
     $response->clearHttpHeaders();
     $response->setContentType('application/vnd.ms-excel');
     $response->setHttpHeader('Content-disposition', "attachment; 
filename=newsletter_".date("YmdHis").".csv");
     $this->layout(false);
     $this->setTemplate('listCsvReportSuccess');
 
     $this->headers = array(
          "Nom", "Email", "Actif", "Utilisateur enregistré ?"
     );
 
     $this->lines = array();
     $this->lines[] = array("my name", "[email protected]", "1", "0");
}

This code results in my browser displaying an error : File not found. Firefox 
cannot find the file at the url 
http://127.0.0.1:8081/users_dev.php/newsletter/ListCsvReport/action
 
OTOH, if I comment some lines in my method :
// $response->clearHttpHeaders();
// $this->layout(false);
// $this->setTemplate('listCsvReportSuccess');

my browser downloads a .csv file. Unfortunately, the file displays uncool data 
such as HTML and PHP code but not a single line of my template, except the 
cryptic  
<td 
title='C:\wamp\www\Compagnie\apps\users\modules\newsletter\templates\listCsvReportSuccess.php'
 bgcolor='#eeeeec'>..\listCsvReportSuccess.php<b>:</b>4</td></tr>
 
Obviously, I'm missing some elephant. Can you point me to the right direction ? 

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to