PHP导出MySQL数据库为EXCEL文件格式(.xls)的方法 http://www.kankanblog.com/read.php/144.htm

name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4493046151883397&dt=1183094806156&lmt=1183094571&format=468x60_as&output=html&correlator=1183094806046&url=http%3A%2F%2Fwww.kankanblog.com%2Fread.php%2F144.htm&color_bg=FFFFFF&color_text=FF0000&color_link=009900&color_url=009900&color_border=009900&ad_type=text_image&ref=http%3A%2F%2Fwww.google.cn%2Fsearch%3Fcomplete%3D1%26hl%3Dzh-CN%26newwindow%3D1%26q%3Dxls%2Bxml%2Boffice%253Aexcel%26btnG%3DGoogle%2B%25E6%2590%259C%25E7%25B4%25A2%26meta%3D&cc=100&flash=9&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="468" scrolling="no" height="60" allowtransparency="allowtransparency">使用 PHP导出 MySQL数据库中的数据,文本格式为下面的格式,但导出的文件后缀名保存为 EXCEL表格的后缀名:xls,导出的数据就是 Excel文件了。

Table标签中的数据可以循环输出,就是你要导出到Excel表格文件中的数据。
相反的方法,可以把已经导出的数据导入 MySQL数据库
(可以把下面信息保存为 Xls文件看看效果)

HTML标签的属性如:颜色 color,bgcolor,font size等可以使用。
具体的实现代码可以参考 这里

<html xmlns:o=" urn:schemas-microsoft-com:office:office"
       xmlns:x=" urn:schemas-microsoft-com:office:excel"
       xmlns=" http://www.w3.org/TR/REC-html40">
<head>
       <meta http-equiv="expires" content="Mon, 06 Jan 1999 00:00:01 GMT">
       <meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
       <!--[if gte mso 9]><xml>
       <x:ExcelWorkbook>
       <x:ExcelWorksheets>
               <x:ExcelWorksheet>
               <x:Name></x:Name>
               <x:WorksheetOptions>
                       <x:DisplayGridlines/>
               </x:WorksheetOptions>
               </x:ExcelWorksheet>
       </x:ExcelWorksheets>
       </x:ExcelWorkbook>
       </xml><![endif]-->
</head>
<body link=blue vlink=purple leftmargin=0 topmargin=0>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td align="center" class="big6" >Users</td></tr>
<tr><td bgcolor=red>
  <table border="1" align="center" width="100%" cellpadding="1" cellspacing="1">
 <tr align="center">
     <td class="TableTopHeader" nowrap>
     Login   </td>
  <td class="TableTopHeader" nowrap>
     Name   </td>
  <td class="TableTopHeader" width="3%" nowrap>
     EMail   </td>
  <td class="TableTopHeader" nowrap>
   Department   </td>
  <td class="TableTopHeader" nowrap>
   Position   </td>
  <td class="TableTopHeader" nowrap width="1%">
    Level   </td>
  <td class="TableTopHeader">Address</td>
  <td class="TableTopHeader">Phone</td>
</tr>
    <tr  class="even">    
     <td class="mtlist">King</td>
     <td class="mtlist"><b>Sangern</b></td>
     <td class="mtlist" >XX@Gmail.com</td>
     <td class="mtlist">Interneter</td>
     <td class="mtlist">SEO</td>
     <td class="mtlist">Admin</td>      
     <td class="mtlist">SH</td>
     <td class="mtlist">110</td>
 </tr>

 </table>
</td></tr>  
</table>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值