Código PHP:
ob_start();
echo " <center><table border=\"1\" align=\"center\">";
//echo "<tr>
//<td></td><td><font color=\"#000000\"><strong>informe sobre l'ultim control:</strong></font></td>
//</tr>";
echo "<tr bgcolor=\"#336666\">
<td><font color=\"#ffffff\"><strong>CODI</strong></font></td>
<TD><font color=\"#ffffff\"><strong>TESTDIM</strong></font></TD>
<td><font color=\"#ffffff\"><strong>LLET</strong></font></td>
<td><font color=\"#ffffff\"><strong>GRASA</strong></font></td>
<td><font color=\"#ffffff\"><strong>CELULES</strong></font></td>
<td><font color=\"#ffffff\"><strong>PROTEINES</strong></font></td>
<td><font color=\"#ffffff\"><strong>LACTACIO</strong></font></td>
<td><font color=\"#ffffff\"><strong>ULTIM PART</strong></font></td>
</tr>";
while($row=mysql_fetch_array($result))
{
echo "<tr>";
for($j=0; $j<$campos; $j++) {
echo "<td>".$row[$j]."</td>";
}
echo "</tr>";
}
echo "</table>";
$reporte = ob_get_clean();
/********************************************
Set the automatic downloadn section
/********************************************/
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=informe-ultimcontrol-.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $reporte;
en definitiva porque usamos esto, y de donde viene, tengo que explicarlo en un trabajo :P
gracias :P