Colocas por ejemplo todos los headers que te indiqué al principio del documento y todo lo que imprimas en pantalla debe guardarse en el excel. Es decir con hacer
Código PHP:
Ver original<?php
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 header('Content-Transfer-Encoding: none'); header('Content-Type: application/vnd.ms-excel'); // This should work for IE & Opera header('Content-type: application/x-msexcel'); // This should work for the rest header('Content-Disposition: attachment; filename="nombre.xls"');
echo '<table xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
<tr>
<td>Foo</td>
</tr>
</table>';
Eso debe crear un excel con una columna y esta debe tener Foo como valor.