note 35921 added to function.header

From: Date: Fri, 19 Sep 2003 07:02:16 +0000
Subject: note 35921 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-56745@lists.php.net to get a copy of this message
while looking for a solution to easily convert HTML->excel spreadsheets, while re-using as much of the existing template system as possible. i stumbled across a nifty little trick with headers that does the job nicely. (note: i have only tested with IE 5.5+). Just call the headers before the HTML that you want to be rendered into a excel document, and there u go example: --------[snip]-------- <?php header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=\"test.xls\""); ?> <table border="1" cellpadding="3" cellspacing="1"> <tr> <td>CustomerID</td> <td>CompanyName</td> <td>ContactName</td> </tr> </table> words words words --------[snip]-------- hope it helps someone, as it saved me doing it with an external excel writer library ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35921 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35921&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35921&report=yes

« previous php.notes (#56745) next »