Try http://api.drupal.org/api/5/function/drupal_set_header On 2/1/07, Ernst Plüss <ernst.pluess@gmail.com> wrote:
Thanks for your answers guis!
What I did so far: 1. generated the content of the excel file and store it in a variable 2. sent the appropriate http-header information 3. sent the excel file with print $exel_contet;
First this works fine for the user, he gets the download popup and stores the file. But the next time the user clicks on a drupal link he gets this:
warning: Cannot modify header information - headers already sent by (output started at
C:\apachefriends\xampp\htdocs\istl\modules\simplenews\simplenews.module:1729) in C:\apachefriends\xampp\htdocs\istl\includes\common.inc on line 269.
I'm sure to not have any spaces sent before my header information is sent. But somehow drupal isn't happy that I'm sending header informations myself.
This is my code: if ($where && $where_tid) { $query = 'SELECT DISTINCT s.mail, s.name FROM {sn_subscriptions} s INNER JOIN {sn_snid_tid} t ON s.snid = t.snid WHERE ('.$where.') AND ('.$where_tid.')'; $result = db_query($query); while ($mail = db_fetch_object($result)) { $mails[] = $mail; } }
$data = "Name\tEmail\n"; foreach($mails as $entry) { $line = simplenews_clean_value($entry->name); $line .= simplenews_clean_value($entry->mail); $data .= trim($line)."\n"; } $data = str_replace("\r","",$data); header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename=news_export.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$data";
Any ideas? TIA Ernst
-- Regards, Johan Forngren johan@forngren.com :: http://johan.forngren.com/