Excel Export with PHP

Excel Export with PHP

This tutorial shows an easy way to create Excel documents dynamically with a PHP script more >>

Contents

Send Header

<?
 header("Content-type: application/vnd-ms-excel"); 
 header("Content-Disposition: attachment; filename=export.xls");
?>

Create Table

Usually you would create the following code dynamically from a database:

<table cellpadding="0" cellspacing="0" border="1">
<tr>
 <th><b>User-ID</b> </th>
 <th><b>Name</b></th>
 <th><b>Wohnort</b></th>
</tr>
<tr>
 <td>243</td>
 <td>Homer Simpson</td>
 <td><font color ="red">Springfield</font></td>
</tr>
<tr>
 <td>265</td>
 <td>Fred Feuerstein</td>
 <td><i>Felsental</i></td>
</tr>
</table>