这个也太简单了。就把你查询到的东西echo出来就是了,导出下载也是一样的

解决方案 »

  1.   

    我以前做过个相似的东东
    我是导出成txt文件的,然后每个导出的字段间用“tab”键分隔,一条记录结束用“\n”换行,
    这样导出来的txt文件可以直接用excel打开看,每个字段都在相应的表格里
      

  2.   

    直接输出文件,扩展名为xls就可以,例子如下:
    <?
    function outexcel($row)
    {
    echo $row["发送号"]."\t";
    echo $row["接收号"]."\t";
    //echo $row["发送时间"]."\t";
    echo $row["年"]."-".$row["月"]."-".$row["日"]." ";
    echo $row["时"].":";
    echo $row["分"].":";
    echo $row["秒"]."\t";
    echo str_replace("\n"," ",$row["内容"])."\t";
    //echo $row["内容"]."\t";
    printf("%.2f\n",$row["消费"]);
    }Header("Content-type: application/octet-stream");
    Header("Accept-Ranges: bytes");
    Header("Content-type:application/vnd.ms-excel");
    Header("Content-Disposition:attachment;filename=".date("Y年m月d日H时i分s秒").".xls");require("config.inc.php");
    echo "发送方\t接收方\t发送时间\t短信内容\t消费金额\n";$sql_link = mssql_connect($host,$username,$password) or die("无法连接数据库服务器!");
    mssql_select_db($db,$sql_link) or die("无法连接数据库!");$query ="SELECT msg.From_String 发送号,msg.To_String 接收号,Year(fh.FeeTime)'年',
           Month(fh.FeeTime) '月',Day(fh.FeeTime) '日',DatePart(hh,fh.FeeTime) '时',
           DatePart(mi,fh.FeeTime) '分',DatePart(ss,fh.FeeTime) '秒',Context 内容,
           fh.Fee 消费
           FROM MobileMessage msg,FeeHistory fh
           WHERE fh.ParentID='$parentID' AND
           fh.MobileMessageID=msg.ID
       ORDER BY fh.FeeTime DESC";$result=mssql_query($query,$sql_link) or die("无法执行SQL");if(($NumRows= mssql_num_rows($result))<=0)
    {
    echo "没有纪录\n";
    }
    else 
    {
    //循环输出当前纪录集
    while($row=mssql_fetch_array($result))
    {
    outexcel($row);
    }}?>
      

  3.   

    要不你直接把东西导入word,接下来的工作由word来完成
      

  4.   

    如果我想把查询出来的数据,放到一个xml文件里,应该怎样实现呢?
    还有就是有没有人用
    http://www.soft198.com/index.asp
    这个超级报表呢?