先要把数据按照在excel里显示的样子放在一个字符串里
比如excel里的单元格就要在字符串里用"\t"分隔
换行是"\n"
然后把这个字符串输出到浏览器里header("Content-type:application/vnd.ms-excel");  
header("Content-Disposition:filename=test.xls");  test.xsl是excel文件的名字

解决方案 »

  1.   

    <a href="#"  onclick="document.execCommand('saveas','','testexcel.xls')">另存为XLS</a><input name="exportExcel" onclick="document.execCommand('saveas','','testexcel.xls')" value="另存为XLS">
      

  2.   

    http://blog.jinshu-cn.com/blog/read.php/171.htm
      

  3.   

    http://www.google.com/search?hl=zh-CN&q=php+execl+class&lr=
      

  4.   

    http://bbs.sevenight.com/read.php?tid=62
      

  5.   

    function SaveExcel(obj,filename){
    var data = obj.outerHTML;
    var select = /(\<select)\s*(.*)\>(.*)\<\/select\>/gi;
    data = data.replace(select,"");
    var a=/(<a)\s*(.+?)>(.+?)<\/a>/gi
    var w = window.open("about:blank",null,"height=100,width=100,titlebar=no, status=no,toolbar=no,menubar=no,location=no");
    w.document.write(data.replace(a,"$3"));
    w.document.execCommand("SaveAs",0,filename);
    w.close();
    }
    导出文件格式无限制,xls为excel
      

  6.   

    http://pear.php.net/search.php?q=excel&in=packages&x=0&y=0