Aqui te va este script, ojalá te sirva:
Código PHP:
<?php
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=excel.xls");
$x = 20;
srand((double)microtime()*1000000);
echo "<table>";
echo "<tr>";
echo "<td>No.</td>";
echo "<td>Anaquel</td>";
echo "<td>Exis</td>";
echo "<td>Clave</td>";
echo "<td>Descripcion</td>";
echo "<td></td>";
echo "<td>Costo U</td>";
echo "</tr>";
for ($i = 1; $i <= $x; $i++)
{
echo "<tr>";
echo "<td>" . $i . "</td>";
echo "<td>A" . rand(1,100) . "</td>";
echo "<td>" . rand(1,100) . "</td>";
echo "<td>CLAVE " . $i . "</td>";
echo "<td>PRODUCTO " . $i . "</td>";
echo "<td>$</td>";
echo "<td>" . rand(1,100) . "</td>";
echo "</tr>";
}
echo "</table>";
?>