Código PHP:
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=ClosedBagDetails".$_GET['Id'].".xls");
$sql="SELECT * FROM registro";
$res=mysql_query($sql);
echo "<table>";
while($ob->mysql_fetch_object($res))
{
echo "<tr>";
echo "<td>".$ob->BagCode."</td>";
echo "</tr>";
}
echo "</table>";
Saludos!