比较麻烦,由于你文本的还有可能会增加,最好通过DOM关系去计算后面的,最后的总计就无所谓了,直接用getElementsByName来得到对象循环计算

解决方案 »

  1.   

    自动记算
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>+&nbsp; =</title>
    </head>
    <script type="text/javascript">
    function startCalc(){
      interval = setInterval("calc()",1);
    }
    function calc(){
      
      fi= document.getElementsByName("firstBox");
      //alert(fi[0].value)
      se = document.getElementsByName("secondBox");
      thi = document.getElementsByName("thirdBox");
      for (i=0;i<fi.length;i++){
        thi[i].value=((fi[i].value)*1)+((se[i].value)*1);
      }
      //two = document.autoSumForm.secondBox.value; 
      //document.autoSumForm.thirdBox.value = (one * 1) + (two * 1);
    }
    function stopCalc(){
      clearInterval(interval);
    }
    </script>
    <form name="autoSumForm">
    <input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> = 
    <input type=text name="thirdBox"><br>
    <input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> = 
    <input type=text name="thirdBox"><br>
    <input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> = 
    <input type=text name="thirdBox">
    </form>
    <p> </p>
    </body>
    </html>
      

  2.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>+&nbsp; =</title>
    </head>
    <script type="text/javascript">
    function startCalc(){
      interval = setInterval("calc()",1);
    }
    function calc(){
      //alert("yy");
      fi= document.getElementsByName("firstBox");
      //alert(fi[0].value)
      se = document.getElementsByName("secondBox");
      thi = document.getElementsByName("thirdBox");
      for (i=0;i<fi.length;i++){
        thi[i].value=((fi[i].value)*1)+((se[i].value)*1);
      }
      //two = document.autoSumForm.secondBox.value; 
      //document.autoSumForm.thirdBox.value = (one * 1) + (two * 1);
    }
    function stopCalc(){
      clearInterval(interval);
    }
    function app(){
      o=document.getElementById("aa");
      str=o.innerHTML;
      //alert(str);
      o1=document.getElementById("bb"); 
      //alert(o1.html);
      o1.innerHTML= o1.innerHTML+"</br>"+str;}
    </script>
    <form name="autoSumForm" id="form1">
    <div id="aa"><input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> = 
    <input type=text name="thirdBox"><br></div>
    <input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> = 
    <input type=text name="thirdBox"><br>
    <div id="bb"><input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> = 
    <input type=text name="thirdBox"></div>
    <input type="button" value="append" onclick="app();">
    </form>
    <p> </p>
    </body>
    </html>
    //期待楼下有更好的办法
      

  3.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>+&nbsp; =</title>
    </head>
    <script type="text/javascript">
    function startCalc(){
    var ind = parseInt((event.srcElement.sourceIndex - 7)/4);
      interval = setInterval("calc("+ind+")",1);
    }
    function calc(i){
      
      fi= document.getElementsByName("firstBox");
      //alert(fi[0].value)
      se = document.getElementsByName("secondBox");
      thi = document.getElementsByName("thirdBox");
      //for (i=0;i<fi.length;i++){
        thi[i].value=((fi[i].value)*1)+((se[i].value)*1);
      //}
      //two = document.autoSumForm.secondBox.value; 
      //document.autoSumForm.thirdBox.value = (one * 1) + (two * 1);
    }
    function stopCalc(){
    //var ind = (event.srcElement.sourceIndex - 7)%3;
      clearInterval(interval);
    }
    function comput()
    {
    var result = 0;
    var thirds = document.getElementsByName("thirdBox");
    for (var i=0;i< thirds.length; i++)
    {
      result += parseFloat(thirds[i].value);
    }
    alert(result);}
    </script>
    <form name="autoSumForm">
    <input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> = 
    <input type=text name="thirdBox"><br>
    <input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> = 
    <input type=text name="thirdBox"><br>
    <input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> = 
    <input type=text name="thirdBox">
    <input type=button value="计算" onclick="comput()">
    </form>
    <p> </p>
    </body>
    </html>
    看看是不是这样
      

  4.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>+&nbsp; =</title>
    </head>
    <script type="text/javascript">
    function startCalc(){
      interval = setInterval("calc()",1);}
    function calc(){
      //alert("yy");
      fi= document.getElementsByName("firstBox");
      //alert(fi[0].value)
      se = document.getElementsByName("secondBox");
      thi = document.getElementsByName("thirdBox");
      for (i=0;i<fi.length;i++){
        thi[i].value=((fi[i].value)*1)+((se[i].value)*1);
      }
      //two = document.autoSumForm.secondBox.value; 
      //document.autoSumForm.thirdBox.value = (one * 1) + (two * 1);
    }
    function stopCalc(){
      clearInterval(interval);
    }
    function app(){
      o=document.getElementById("aa");
      str=o.innerHTML;
      //alert(str);
      o1=document.getElementById("bb"); 
      //alert(o1.html);
      o1.innerHTML= o1.innerHTML+"</br>"+str;
    }function sum(){//加总
      thi = document.getElementsByName("thirdBox");
      tot = document.getElementsByName('totalBox');
      tot[0].value="0";
      for(i=0;i<thi.length;i++){
        if(thi[i].value!=''){
          tot[0].value=tot[0].value*1+thi[i].value*1;
    }
      }
    }
    </script>
    <form name="autoSumForm" id="form1">
    <div id="aa"><input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();sum();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();sum();"> = 
    <input type=text name="thirdBox"><br></div>
    <input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();sum();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();sum();"> = 
    <input type=text name="thirdBox"><br>
    <div id="bb"><input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();sum();"> + 
    <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();sum();"> = 
    <input type=text name="thirdBox"></div>
    <input type="button" value="append" onclick="app();sum()"><span style="margin-left:262px">sum:<input type="text" name="totalBox" value="0"></span>
    </form>
    <p> </p>
    </body>
    </html>
      

  5.   

    谢谢大家的回复。问题由yiran5467(依苒)回复的最标准,我一会按功劳给分
    不过还有个问题请教下大家(会继续给分)
      

  6.   

    melodywithme()和 adverse(King)也回复的非常好,谢谢 你们
      

  7.   

    再就是一个查询的问题 关于表格的问题  比如第一列有的占3行 有的占5行 而其他列都是占一行的  象一般的查询所有列都占一行 非常容易实现,而这种情况我不知道该怎么办,高手们帮解决解决。
    例如,下面这个例子是填表时候的样子 这样好实现 但是把它们提交到数据库后  还想按这个样子查询出来,该怎么实现呢?<table  border="1" align="center"  bgcolor="#CCFFFF" class="greenfont">
    <tr><td height="24" colspan="5" align="center"><strong> 计划部分</strong></td>
    <td colspan="2"  align="center"><strong>自评价部分</strong></td>
    <td colspan="2" align="center"><strong>分管领导评价部分</strong></td></tr>
    <tr><td width="28" height="58" align="center">序号</td>
    <td width="13" align="center">分类</td><td width="237" align="center">本周计划内容</td><td width="28" align="center">重要<br>程度</td>
                             <td width="237">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 计划完成时间及进程 </td>
      <td width="237" height="58" align="center">完成情况评价 </td>
                             <td width="28">完成程度评分</td>
                             <td width="125" align="center">完成情况评价</td>
                             <td width="168">完成程度评分</td>
                           </tr>
                           <tr>
                             <td height="55"><input name="xuhao1" type="text"  value="01" size="4"></td>
                             <td rowspan="5" align="center">重<br>要<br>部<br>分</td>
                             <td height="55"><textarea name="content1" cols="32" rows="3" > </textarea></td>
                             <td height="55"><input name="zhongyao1" type="text" size="4" ></td>
                             <td height="55"><textarea name="jihua2" cols="32" rows="3" > </textarea></td>
                             <td height="55"><textarea name="pingjia1" cols="32" rows="3" > </textarea></td>
                             <td height="55"><input name="wancheng1" type="text" size="4"></td>
                             <td><textarea name="qingkuang1" cols="16" rows="3" > </textarea></td>
                             <td><input name="pingfen1" type="text" size="4"></td>
                           </tr>
                           <tr>
                             <td height="25"><input name="xuhao2" type="text"  value="02" size="4"></td>
                             <td height="25"><textarea name="content2" cols="32" rows="3" > </textarea></td>
                             <td height="25"><input name="zhongyao2" type="text"  size="4" ></td>
                             <td height="25"><textarea name="jihua2" cols="32" rows="3" > </textarea></td>
                             <td height="25"><textarea name="pingjia2" cols="32" rows="3" > </textarea></td>
                             <td height="25"><input name="wancheng2" type="text" class="downborder"  size="4" ></td>
                             <td><textarea name="qingkuang2" cols="16" rows="3" > </textarea></td>
                             <td><input name="pingfen2" type="text" size="4" ></td>
                           </tr>
                           <tr>
                             <td height="57"><input name="xuhao3" type="text"  value="03" size="4"></td>
                             <td height="57"><textarea name="content3" cols="32" rows="3" > </textarea></td>
                             <td height="57"><input name="zhongyao3" type="text"  value=" " size="4" ></td>
                             <td height="57"><textarea name="jihua3" cols="32" rows="3" > </textarea></td>
                             <td height="57"><textarea name="pingjia3" cols="32" rows="3"  id="pingjia3" > </textarea></td>
                             <td height="57"><input name="wancheng3" type="text"  value=" " size="4" ></td>
                             <td><textarea name="qingkuang3" cols="16" rows="3" > </textarea></td>
                             <td><input name="pingfen3" type="text" id="pingfen3" value=" " size="4" ></td>
                           </tr>
                           <tr>
                             <td height="55"><input name="xuhao4" type="text" class="downborder" id="xuhao4" value="04" size="4">
                             </td>
                             <td height="55"><textarea name="content4" cols="32" rows="3" > </textarea></td>
                             <td height="55"><input name="zhongyao4" type="text"  value=" " size="4" ></td>
                             <td height="55"><textarea name="jihua4" cols="32" rows="3" > </textarea></td>
                             <td height="55"><textarea name="pingjia4" cols="32" rows="3" > </textarea></td>
                             <td height="55"><input name="wancheng4" type="text"  value=" " size="4" ></td>
                             <td><textarea name="qingkuang4" cols="16" rows="3" > </textarea></td>
                             <td><input name="pingfen4" type="text" value=" " size="4"></td>
                           </tr>
       
      

  8.   

    做过的一个例子,其中ds是类似于ResultSet的集合,你可以根据需要适当修改
    <table id="tb" width="100%" border=0 cellSpacing=1 cellPadding=3 class=deep>
    <tr>
    <th noWrap="true" class="til" align="center"><font color="black"><b>选择</b></font></th>
    <th noWrap="true" class="til" align="center"><b>学号</b></th>
    <th noWrap="true" class="til" align="center"><b>姓名</b></th>
    <th noWrap="true" class="til" align="center"><b>学院</b></th>
    <th noWrap="true" class="til" align="center"><b>专业</b></th>
    <th noWrap="true" class="til" align="center"><b>类型</b></th>
    <th noWrap="true" class="til" align="center"><b>申报日期</b></th>
    <%-- <th noWrap="true" class="til" align="center"><b>院系所号</b></th>--%>
    </tr>
    <tr>
    <td height=5 colspan="15" background='<%=request.getContextPath()%>/js/images/theme/toolbrbk.gif'>
    <img src="<%=request.getContextPath()%>/images/clear.gif" width="1" height="1"></td>
    </tr>
    <%while(ds.next())
    {
    String rowid = ds.getString("ECNUROWID");
    DataSet dds = (DataSet) lx.get(rowid);
    size = dds.getRowCount()>1?dds.getRowCount():1;
    count = size+1;
    %><tr>
    <td width="32" class="itemnum" rowspan="<%=size%>">
    <input type="checkbox" id="rowid" name="rowid" class="check" value="<%=rowid %>">
    </td>
    <td class="lightcell" rowspan="<%=size%>">
    <a href="<%=path%>/student/EmphasesManageAction.do?method=showEmphasesManageDetail&rowid=<%=rowid%>&lsh=<%=rowid%>"><%=ds.getString("XH") == null ? "&nbsp" : ds.getString("XH")%></a>
    </td>
    <td class="lightcell" rowspan="<%=size%>"><%=ds.getString("XM") == null ? "&nbsp" : ds.getString("XM")%></td>
    <td class="lightcell" rowspan="<%=size%>"><%=ds.getString("YXMC") == null ? "&nbsp" : ds.getString("YXMC")%></td>
    <td class="lightcell" rowspan="<%=size%>"><%=ds.getString("ZYMC") == null ? "&nbsp" : ds.getString("ZYMC")%></td>
    <%if(dds.getRowCount() > 0)

    if(dds.next())
    {%>
    <td class="lightcell" rowspan=1><%=dds.getString("MC") == null ? "&nbsp" : dds.getString("MC")%></td>
      <%    }
       }
       else
       {
       %><td class="lightcell" rowspan="<%=size%>">&nbsp;</td><%
       }%>
    <td class="lightcell" rowspan="<%=size%>"><%=ds.getString("SBRQ") == null ? "&nbsp" : ds.getString("SBRQ")%></td>
    <td class="lightcell" rowspan="<%=size%>" style="display:none;"><%=ds.getString("YXSH") == null ? "&nbsp" : ds.getString("YXSH")%></td>
    <script language="javascript">yxshArray[yxshCount++]='<%=ds.getString("YXSH") == null ? "&nbsp" : ds.getString("YXSH")%>';</script>
    </tr><%
    while(dds.next())
    {
    %> <tr><td class="lightcell" rowspan=1><%=dds.getString("MC") == null ? "&nbsp" : dds.getString("MC")%></td></tr><%
    count++;
    }
    } %>
    </table>
      

  9.   

    晕,我上面那个不就是jsp吗。
      

  10.   

    <param name=XMLData
     value="&lt;?xml version=&quot;1.0&quot;?&gt;&#13;&#10;&lt;?mso-application progid=&quot;Excel.Sheet&quot;?&gt;&#13;&#10;&lt;Workbook xmlns=&quot;urn:schemas-microsoft-com:office:spreadsheet&quot;&#13;&#10; xmlns:o=&quot;urn:schemas-microsoft-com:office:office&quot;&#13;&#10; xmlns:x=&quot;urn:schemas-microsoft-com:office:excel&quot;&#13;&#10; xmlns:ss=&quot;urn:schemas-microsoft-com:office:spreadsheet&quot;&#13;&#10; xmlns:html=&quot;http://www.w3.org/TR/REC-html40&quot;&gt;&#13;&#10;&lt;DocumentProperties xmlns=&quot;urn:schemas-microsoft-com:office:office&quot;&gt;&#13;&#10;&lt;Version&gt;11.8122&lt;/Version&gt;&#13;&#10;&lt;/DocumentProperties&gt;&#13;&#10;&lt;ExcelWorkbook xmlns=&quot;urn:schemas-microsoft-com:office:excel&quot;&gt;&#13;&#10;&lt;WindowHeight&gt;9675&lt;/WindowHeight&gt;&#13;&#10;&lt;WindowWidth&gt;14940&lt;/WindowWidth&gt;&#13;&#10;&lt;WindowTopX&gt;240&lt;/WindowTopX&gt;&#13;&#10;&lt;WindowTopY&gt;105&lt;/WindowTopY&gt;&#13;&#10;&lt;ProtectStructure&gt;False&lt;/ProtectStructure&gt;&#13;&#10;&lt;ProtectWindows&gt;False&lt;/ProtectWindows&gt;&#13;&#10;&lt;/ExcelWorkbook&gt;&#13;&#10;&lt;Styles&gt;&#13;&#10;&lt;Style ss:ID=&quot;Default&quot; ss:Name=&quot;Normal&quot;&gt;&#13;&#10;&lt;Alignment ss:Vertical=&quot;Center&quot;/&gt;&#13;&#10;&lt;Borders/&gt;&#13;&#10;&lt;Font ss:FontName=&quot;宋体&quot; x:CharSet=&quot;134&quot; ss:Size=&quot;12&quot;/&gt;&#13;&#10;&lt;Interior/&gt;&#13;&#10;&lt;NumberFormat/&gt;&#13;&#10;&lt;Protection/&gt;&#13;&#10;&lt;/Style&gt;&#13;&#10;&lt;/Styles&gt;&#13;&#10;&lt;Worksheet ss:Name=&quot;TEST&quot;&gt;&#13;&#10;&lt;Table ss:ExpandedColumnCount=&quot;7&quot; ss:ExpandedRowCount=&quot;7&quot; x:FullColumns=&quot;1&quot;&#13;&#10;x:FullRows=&quot;1&quot; ss:DefaultColumnWidth=&quot;54&quot; ss:DefaultRowHeight=&quot;14.25&quot;&gt;&#13;&#10;&lt;Column ss:Width=&quot;31.5&quot; ss:Span=&quot;4&quot;/&gt;&#13;&#10;&lt;Column ss:Index=&quot;6&quot; ss:Width=&quot;36&quot;/&gt;&#13;&#10;&lt;Column ss:Width=&quot;27&quot;/&gt;&#13;&#10;&lt;Row&gt;&#13;&#10;&lt;Cell ss:MergeAcross=&quot;5&quot; &gt;&lt;Data ss:Type=&quot;String&quot;&gt;TEST&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;/Row&gt;&#13;&#10;&lt;Row&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;/Row&gt;&#13;&#10;&lt;Row&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;/Row&gt;&#13;&#10;&lt;Row&gt;&#13;&#10;&lt;Cell &gt;&lt;Data ss:Type=&quot;String&quot;&gt;字段1&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell &gt;&lt;Data ss:Type=&quot;String&quot;&gt;字段2&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell &gt;&lt;Data ss:Type=&quot;String&quot;&gt;本期&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell &gt;&lt;Data ss:Type=&quot;String&quot;&gt;累计&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell &gt;&lt;Data ss:Type=&quot;String&quot;&gt;指标&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell &gt;&lt;Data ss:Type=&quot;String&quot;&gt;完成度&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell &gt;&lt;Data ss:Type=&quot;String&quot;&gt;排名&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;/Row&gt;&#13;&#10;&lt;Row&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell  ss:Formula=&quot;=IF(RC[-1]&amp;lt;&amp;gt;0,RC[-2]/RC[-1],0)&quot;&gt;&lt;Data&#13;&#10;ss:Type=&quot;Number&quot;&gt;0&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;/Row&gt;&#13;&#10;&lt;Row&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell  ss:Formula=&quot;=IF(RC[-1]&amp;lt;&amp;gt;0,RC[-2]/RC[-1],0)&quot;&gt;&lt;Data&#13;&#10;ss:Type=&quot;Number&quot;&gt;0&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;/Row&gt;&#13;&#10;&lt;Row&gt;&#13;&#10;&lt;Cell &gt;&lt;Data ss:Type=&quot;String&quot;&gt;合计&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;Cell  ss:Formula=&quot;=SUM(R[-2]C:R[-1]C)&quot;&gt;&lt;Data ss:Type=&quot;Number&quot;&gt;0&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell  ss:Formula=&quot;=SUM(R[-2]C:R[-1]C)&quot;&gt;&lt;Data ss:Type=&quot;Number&quot;&gt;0&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell  ss:Formula=&quot;=SUM(R[-2]C:R[-1]C)&quot;&gt;&lt;Data ss:Type=&quot;Number&quot;&gt;0&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell  ss:Formula=&quot;=IF(RC[-1]&amp;lt;&amp;gt;0,RC[-2]/RC[-1],0)&quot;&gt;&lt;Data&#13;&#10;ss:Type=&quot;Number&quot;&gt;0&lt;/Data&gt;&lt;/Cell&gt;&#13;&#10;&lt;Cell /&gt;&#13;&#10;&lt;/Row&gt;&#13;&#10;&lt;/Table&gt;&#13;&#10;&lt;WorksheetOptions xmlns=&quot;urn:schemas-microsoft-com:office:excel&quot;&gt;&#13;&#10;&lt;Print&gt;&#13;&#10;&lt;ValidPrinterInfo/&gt;&#13;&#10;&lt;PaperSizeIndex&gt;9&lt;/PaperSizeIndex&gt;&#13;&#10;&lt;HorizontalResolution&gt;600&lt;/HorizontalResolution&gt;&#13;&#10;&lt;VerticalResolution&gt;600&lt;/VerticalResolution&gt;&#13;&#10;&lt;/Print&gt;&#13;&#10;&lt;ProtectObjects&gt;False&lt;/ProtectObjects&gt;&#13;&#10;&lt;ProtectScenarios&gt;False&lt;/ProtectScenarios&gt;&#13;&#10;&lt;/WorksheetOptions&gt;&#13;&#10;&lt;/Worksheet&gt;&#13;&#10;&lt;/Workbook&gt;&#13;&#10;">
      

  11.   

    用Office 2003 Web Components做的,用来展现报表还是不错的,不过客户端最好装了office2003发不下, 分段了, 用上面的 <param name=XMLData  value="....">替换本文中的 <param name=XMLData  value=""><html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head>
    <meta http-equiv=Content-Type content="text/html; charset=gb2312">
    <title>Excel</title>
    <script language="JavaScript">
    <!--
    //要填写的单元格
    var datas = new Array(
    'A3','统计月份:2007年03月'
    );//数据行,字段用|分隔,[#COPY]表示不改动原Excel表格数据(如公式)
    var records = new Array(
    "AAA|A1|44|114|40|[#COPY]|1",
    "AAA|A2|75|230|100|[#COPY]|2",
    "AAA|A3|21|67|80|[#COPY]|3",
    "BBB|B1|10|70|20|[#COPY]|4",
    "BBB|B2|51|98|0|[#COPY]|5",
    "CCC|C1|0|0|0|[#COPY]|6",
    "CCC|C2|0|0|0|[#COPY]|7",
    ""
    );var start_row = 5; //数据行开始的位置
    var arrMarginCols = "A".split(","); //要合并的列, 如:"A,C,AA"function GetColName(c) {
    return (c>26?GetColName(Math.floor(c/26)):"") + String.fromCharCode(64 + c % 26);
    }function Spreadsheet_Setting() {
    try {
    var i, j;
    var e = document.all.RepostSpreadsheet; var fmt_row = start_row, recordnum = records.length - 1; //插入行并复制格式
    for (var i=recordnum; i<2; i++)
    e.Rows(fmt_row).Delete();
    if (recordnum>2) {
    e.Rows(fmt_row + ":" + fmt_row).Select();
    e.Selection.Copy();

    e.Rows((fmt_row + 1) + ":" + (fmt_row + recordnum - 2)).Select();
    e.Selection.Insert();
    e.ActiveSheet.Paste();
    }
    //设置记录集数据
    var tmpFormula, tmpRecord, tmpFields;
    for (i=0; i<recordnum; i++) {
    tmpRecord = "";
    tmpFields = records[i].replace(/\[#ROW\]/ig, fmt_row + i).split("|");
    for (j=0; j<tmpFields.length; j++) {
    tmpFormula = tmpFields[j].replace(/\[#COPY\]/ig, e.Cells(fmt_row + i, j + 1).Formula).replace(/\[#COL\]/ig, GetColName(j + 1));
    tmpRecord += (j==0?"":"|") + tmpFormula;
    }
    e.Rows((fmt_row + i) + ":" + (fmt_row + i)).ParseText(tmpRecord, "|");
    }

    //合并列单元格
    var MARGIN_STAR;
    for (i=0; i<arrMarginCols.length; i++) {
    tmpFormula = "";
    MARGIN_START = fmt_row + recordnum;
    MARGIN_COL = arrMarginCols[i];
    for (j=MARGIN_START; fmt_row - 1<=j; j--) {
    if (e.Range(MARGIN_COL + j).Formula!=tmpFormula) {
    if (MARGIN_START - j>1) {
    e.Range(MARGIN_COL + (j + 1) + ":" + MARGIN_COL + MARGIN_START).Select();
    e.Selection.Merge();
    }
    MARGIN_START = j;
    tmpFormula = e.Range(MARGIN_COL + j).Formula;
    }
    }
    }

    //设置数据
    for (i=0; i<datas.length; i+=2)
    e.Range(datas[i]).Formula = datas[i+1];
    //最合适列宽度
    e.Columns.EntireColumn.AutoFit();

    e.Range("A1").Select();
    } catch (e) {
    alert(e.description);
    }
    }window.onload = function() {
    Spreadsheet_Setting();
    }
    //-->
    </SCRIPT>
    </head><body topmargin="0" leftmargin="0" scroll="no">
    <object id="RepostSpreadsheet" height="100%" width="100%" codebase="/itnet/Templates/owc11.exe" classid="CLSID:0002E559-0000-0000-C000-000000000046">
    <param name=DisplayTitleBar value=false>
     <param name=DataType value=XMLData>
     <param name=XMLData  value="">
     <p style='margin-top:100;font-family:宋体;font-size:8.0pt'>要交互式地使用此网页,您必须有
     Microsoft&reg; Internet Explorer 5.01 Service Pack 1 (SP2) 或更新版本,以及 Microsoft
     Office 2003 Web Components。</p>
     <p style='margin-top:100;font-family:宋体;font-size:8.0pt'>请访问 <a
     href="http://r.office.microsoft.com/r/rlidmsowcpub?clid=2052&amp;p1=Excel">Microsoft
     Office 网站</a> 以获取更多信息。</p>
    </object></body>
    </html>
      

  12.   

    用Office 2003 Web Components你可以定义很复杂和展现的Excel报表, 然后用上面这个模板程序展现出来, 因为发布内容长度限制, 我的例子报表定义的很简陋。Excel模板制作的说明:
    以上面的Excel为例,要注意的是一定要保留标题行和合计行中间的两个空数据行,如下5,6行
    A |B |C |D |E |F |G
      ---------------------------------------------------
    1|TEST
    2|
    3|
    4|字段1 字段2 本期 累计 指标 完成度 排名
    5| 公式
    6| 公式
    7|合计 公式 公式 公式 公式 按上面制作Excel后,"文件-->另存为网页",注意选择"添加交互",保存页面后,用保存页面中的<param name=XMLData  value="....">替换本文中的 <param name=XMLData  value="">
    就可以应用你的新Excel表了