1. header ('Content-type: application/x-msexcel');
  2. header ("Content-Disposition: attachment; filename=$filename");
  3. header("Pragma: no-cache");
  4. header("Expires: 0");
  5. echo '<html xmlns:o="urn:schemas-microsoft-com:office:office"
  6. xmlns:x="urn:schemas-microsoft-com:office:excel"
  7. xmlns="http://www.w3.org/TR/REC-html40">
  8. <head>
  9. <meta http-equiv="expires" content="Mon, 06 Jan 1999 00:00:01 GMT">
  10. <meta http-equiv=Content-Type content="text/html; charset=gb2312">
  11. <!--[if gte mso 9]><xml>
  12. <x:ExcelWorkbook>
  13. <x:ExcelWorksheets>
  14. <x:ExcelWorksheet>
  15. <x:Name></x:Name>
  16. <x:WorksheetOptions>
  17. <x:DisplayGridlines/>
  18. </x:WorksheetOptions>
  19. </x:ExcelWorksheet>
  20. </x:ExcelWorksheets>
  21. </x:ExcelWorkbook>
  22. </xml><![endif]-->
  23. </head>';
  24. echo '<table><tr>';
  25. echo "<td>客户姓名</td>";
  26. echo "<td>客户手机</td>";
  27. echo "<td>身份证号</td>";
  28. echo "<td>客户地址</td>";
  29. echo "<td>申请银行</td>";
  30. echo "<td>额度</td>";
  31. echo '</tr>';
  32. $result=$db->query($sql);
  33. $num=$db->num_row($result);
  34. if ($num==0)
  35. {
  36. echo "真遗憾,没有相符合条件的数据!";
  37. exit;
  38. }
  39. while($rows=$db->fetch($result))
  40. {
  41. echo '<tr>';
  42. echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['name']."</td>";
  43. echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['phone']."</td>";
  44. echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['card']."</td>";
  45. echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['address']."</td>";
  46. echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['bank']."</td>";
  47. echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['quota']."</td>";
  48. echo '</tr>';
  49. }
  50. echo '</table>';