写一个固定格式的excel(格式和你要求的报表格式大致相同)另存为一个html文件,打开后查看源代码,将代码copy到jsp中,将代码中显示产品的信息的地方改成相应的jsp标签

解决方案 »

  1.   

    copy from other one!  copy and paste the codes below into notepad,then use ie browse it .you will see the result then analy it. <%@ 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.   

    dawangzi16(大望子)  的脚本好像不能正常使用
      

  3.   

    HTML自带的CONTENTTYPE="EXCEL的标识"
      

  4.   

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

  5.   

    实现了,就用jExcelApi ,谢谢各位的关注!