<script>
var ExcelSheet;
ExcelApp = new ActiveXObject("Excel.Application");
ExcelSheet = new ActiveXObject("Excel.Sheet");
ExcelSheet.Application.Visible = true;
/*下面写入数据,可以嵌合php代码,逐一生成js写入语句*/
ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
ExcelSheet.ActiveSheet.Cells(1,2).Value = "This is column A, row 2";
ExcelSheet.ActiveSheet.Cells(2,1).Value = "This is column B, row 1";
ExcelSheet.ActiveSheet.Cells(2,2).Value = "This is column B, row 2";
ExcelSheet.SaveAs("C:\\xxx.XLS");
ExcelSheet.Application.Quit();
</script>
条件是更改ie设置:
设置->安全性->自定义
将初始化不安全的activeX控制项设置为启用

解决方案 »

  1.   

    echo "content-type", "application/x-msexcel";
    再用制表符
    echo "1  2  3";
    空格为制表符
      

  2.   

    <?php
    header("Content-type: application/x-msexcel");
    //include("test.asp");
    ?>
    <html>
    <head>
    <title>abc</title>
    </head>
    <body>
    <table border=1 borderlightcolor=black borderdarkcolor=white>
    <tr>
    <td style="font-size=12px">abc</td>
    </tr>
    </table>
    </body>
    </html>要对excel中显示的数据进行修饰,必须使用CSS。
      

  3.   

    <?php
    header("Content-type: application/x-msexcel");
    //include("test.asp");
    ?>
    <html>
    <head>
    <title>abc</title>
    </head>
    <body>
    <table border=1 borderlightcolor=black borderdarkcolor=white>
    <tr>
    <td style="font-size=12px; font-color=red" align=center>abc</td>
    </tr>
    </table>
    </body>
    </html>
      

  4.   

    呵呵,更正一下:
    <td style="font-size:12px; font-color:red" align=center>abc</td>
      

  5.   

    header("Content-type: application/x-msexcel");
    echo "1  2  3";