将数据读出,然后输出为EXCEL格式的文件

解决方案 »

  1.   

    <?php
    header("Content-type:application/vnd.ms-excel");
    header("Content-Disposition:filename=test.xls");
    ?>
    <html>
    <head>
    <meta http-equiv=Content-Type content="text/html; charset=GB2312">
    <style>
    <!--
    .xl24
    {font-size:20.0pt;
    font-family:楷体_GB2312, monospace;
    text-align:center;
    vertical-align:middle;
    white-space:normal;}
    .xl25
    {text-align:center;
    vertical-align:middle;
    border:.5pt solid windowtext;
    white-space:normal;}
    .xl26
    {vertical-align:middle;
    border:.5pt solid windowtext;
    white-space:normal;}
    .xl27
    {text-align:center;
    vertical-align:middle;
    border:.5pt solid windowtext;
    white-space:normal;}
    .xl28
    {font-family:黑体;
    text-align:center;
    vertical-align:middle;
    border:.5pt solid windowtext;
    white-space:normal;}
    .xl29
    {text-align:left;
    vertical-align:middle;
    border:.5pt solid windowtext;
    white-space:normal;}
    -->
    </style>
    </head>
    <body bgcolor="#FFFFFF">
    <table x:str border=0 cellpadding=0 cellspacing=0 width=960>
      <tr height=50> 
        <td colspan=8 height=50 class=xl24 width=960>() 至 () 
          收费统计分析</td>
      </tr>
      <tr height=30> 
        <td class=xl28 height=30  width=60>序号</td>
        <td class=xl28 width=300>客户名称</td>
        <td class=xl28 width=100>收费项目</td>
        <td class=xl28 width=120>金额</td>
        <td class=xl28 width=100>方式</td>
        <td class=xl28 width=120>完成时间</td>
        <td class=xl28 width=80>状态</td>
        <td class=xl28 width=80>业务员</td>
      </tr>
    <?php
    For($I = 1;$I < 10 ;$I++)
    {
    ?>
      <tr height=30> 
        <td height=30 class=xl25 width=60 x:num><?=$I?></td>
        <td class=xl26 width=300>a</td>
        <td class=xl25 width=100>b</td>
        <td class=xl26 width=120>c</td>
        <td class=xl25 width=100>d</td>
        <td class=xl29 width=120>e</td>
        <td class=xl27 width=80>f</td>
        <td class=xl25 width=80x:num>g</td>
      </tr>
    <?php
    }
    ?>
      <tr height=26> 
        <td height=26 class=xl28>合计</td>
        <td colspan='2' class=xl26>元</td>
        <td height=26 class=xl28>制表时间</td>
        <td colspan='2' class=xl26></td>
        <td height=26 class=xl28>制表人</td>
        <td class=xl26></td>
      </tr>
    </table>
    </body>
    </html>
      

  2.   

    cu上的一篇讨论php将mysql数数导成EXCEL文档
    http://bbs.chinaunix.net/forum/viewtopic.php?t=172598希望对你有帮助~~~传说微软将公布EXCEL的XML格式
    http://bbs.chinaunix.net/forum/viewtopic.php?t=204738