document.execCommand("SaveAs","","d:\\index.htm");
我只会手动调用IE的SaveAs功能,还要对话框进行选择,怎么才能自动保存呢
唉csdn上人才凋零了吗,一声叹息

解决方案 »

  1.   

    <%@ page contentType="text/html; charset=GBK"%>
    <input type="hidden" name="out_excel" onclick="AutomateExcel();" value="导出到excel" class="notPrint"> <title>浏览器表格导出到Excel</title>
    <input type="button" name="out_word1" onclick="javascript:AutomateExcel() " value="导出到excel" class="notPrint"> 
    <table id="data" width="200" border="1">
      <tr>
        <td>我是李春雷</td>
        <td>11</td>
      </tr>
      <tr>
        <td>22</td>
        <td>22</td>
      </tr>
      <tr>
        <td>33</td>
        <td>33</td>
      </tr>
      <tr>
        <td>44 </td>
        <td>44</td>
      </tr>
    </table>
    我是李春雷
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function AutomateExcel() 
    {
    // Start Excel and get Application object.
    var oXL = new ActiveXObject("Excel.Application"); 
    // Get a new workbook.
    var oWB = oXL.Workbooks.Add();
    var oSheet = oWB.ActiveSheet;
    var table = document.all.data; 
    var hang = table.rows.length;var lie = table.rows(0).cells.length; // Add table headers going cell by cell.
    for (i=0;i<hang;i++)
    {
    for (j=0;j<lie;j++)
    {
    oSheet.Cells(i+1,j+1).Value = table.rows(i).cells(j).innerText;
    }}
    oXL.Visible = true;
    oXL.UserControl = true;
    }
    //-->
    </SCRIPT>
      

  2.   

    copy from other .      Just copy and paste the codes into notepad, then save and browse it from ie.You will see the result
      

  3.   

    可以试试FineReport, 纯java格子报表
    http://www.finereport.com