亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

javascript操作excel生成報(bào)表示例

 更新時(shí)間:2014年05月08日 10:28:09   作者:  
最近做一個(gè)項(xiàng)目,用到j(luò)avascript操縱excel以生成報(bào)表,下面是標(biāo)有詳細(xì)注解的實(shí)例

復(fù)制代碼 代碼如下:

<html>

<head>
<script language="javascript" type="text/javascript">
function MakeExcel(){
var i,j;
    try {
      var xls    = new ActiveXObject ( "Excel.Application" );
     }
    catch(e) {
         alert( "要打印該表,您必須安裝Excel電子表格軟件,同時(shí)瀏覽器須使用“ActiveX 控件”,您的瀏覽器須允許執(zhí)行控件。 請(qǐng)點(diǎn)擊【幫助】了解瀏覽器設(shè)置方法!");
              return "";
     }

            xls.visible =true;  //設(shè)置excel為可見(jiàn)

    var xlBook = xls.Workbooks.Add;
    var xlsheet = xlBook.Worksheets(1);
    <!--合并-->
      xlsheet.Range(xlsheet.Cells(1,1),xlsheet.Cells(1,7)).mergecells=true;
      xlsheet.Range(xlsheet.Cells(1,1),xlsheet.Cells(1,7)).value="發(fā)卡記錄";
     //  xlsheet.Range(xlsheet.Cells(1,1),xlsheet.Cells(1,6)).Interior.ColorIndex=5;//設(shè)置底色為藍(lán)色
                //   xlsheet.Range(xlsheet.Cells(1,1),xlsheet.Cells(1,6)).Font.ColorIndex=4;//設(shè)置字體色        
   // xlsheet.Rows(1). Interior .ColorIndex = 5 ;//設(shè)置底色為藍(lán)色  設(shè)置背景色 Rows(1).Font.ColorIndex=4 

    <!--設(shè)置行高-->
    xlsheet.Rows(1).RowHeight = 25;
    <!--設(shè)置字體 ws.Range(ws.Cells(i0+1,j0), ws.Cells(i0+1,j1)).Font.Size = 13 -->
    xlsheet.Rows(1).Font.Size=14;
    <!--設(shè)置字體 設(shè)置選定區(qū)的字體  xlsheet.Range(xlsheet.Cells(i0,j0), ws.Cells(i0,j0)).Font.Name = "黑體" -->
    xlsheet.Rows(1).Font.Name="黑體";
    <!--設(shè)置列寬 xlsheet.Columns(2)=14;-->

    xlsheet.Columns("A:D").ColumnWidth =18;
     <!--設(shè)置顯示字符而不是數(shù)字-->
    xlsheet.Columns(2).NumberFormatLocal="@";
    xlsheet.Columns(7).NumberFormatLocal="@";


     //設(shè)置單元格內(nèi)容自動(dòng)換行 range.WrapText  =  true  ;
     //設(shè)置單元格內(nèi)容水平對(duì)齊方式 range.HorizontalAlignment  =  Excel.XlHAlign.xlHAlignCenter;//設(shè)置單元格內(nèi)容豎直堆砌方式
      //range.VerticalAlignment=Excel.XlVAlign.xlVAlignCenter
    //range.WrapText  =  true;  xlsheet.Rows(3).WrapText=true  自動(dòng)換行

    //設(shè)置標(biāo)題欄

     xlsheet.Cells(2,1).Value="卡號(hào)";
     xlsheet.Cells(2,2).Value="密碼";
     xlsheet.Cells(2,3).Value="計(jì)費(fèi)方式";
     xlsheet.Cells(2,4).Value="有效天數(shù)";
     xlsheet.Cells(2,5).Value="金額";
     xlsheet.Cells(2,6).Value="所屬服務(wù)項(xiàng)目";
       xlsheet.Cells(2,7).Value="發(fā)卡時(shí)間";

     var oTable=document.all['fors:data'];
     var rowNum=oTable.rows.length;
     for(i=2;i<=rowNum;i++){
     for (j=1;j<=7;j++){
//html table類容寫到excel

       xlsheet.Cells(i+1,j).Value=oTable.rows(i-1).cells(j-1).innerHTML;
            }


    }
    <!--   xlsheet.Range(xls.Cells(i+4,2),xls.Cells(rowNum,4)).Merge; -->
    // xlsheet.Range(xlsheet.Cells(i, 4), xlsheet.Cells(i-1, 6)).BorderAround , 4
     // for(mn=1,mn<=6;mn++) .     xlsheet.Range(xlsheet.Cells(1, mn), xlsheet.Cells(i1, j)).Columns.AutoFit;
      xlsheet.Columns.AutoFit;
                 xlsheet.Range( xlsheet.Cells(1,1),xlsheet.Cells(rowNum+1,7)).HorizontalAlignment =-4108;//居中
                   xlsheet.Range( xlsheet.Cells(1,1),xlsheet.Cells(1,7)).VerticalAlignment =-4108;
                 xlsheet.Range( xlsheet.Cells(2,1),xlsheet.Cells(rowNum+1,7)).Font.Size=10;

      xlsheet.Range( xlsheet.Cells(2,1),xlsheet.Cells(rowNum+1,7)).Borders(3).Weight = 2; //設(shè)置左邊距
       xlsheet.Range( xlsheet.Cells(2,1),xlsheet.Cells(rowNum+1,7)).Borders(4).Weight = 2;//設(shè)置右邊距
             xlsheet.Range( xlsheet.Cells(2,1),xlsheet.Cells(rowNum+1,7)).Borders(1).Weight = 2;//設(shè)置頂邊距
       xlsheet.Range( xlsheet.Cells(2,1),xlsheet.Cells(rowNum+1,7)).Borders(2).Weight = 2;//設(shè)置底邊距

 

      
        xls.UserControl = true;  //很重要,不能省略,不然會(huì)出問(wèn)題 意思是excel交由用戶控制
       xls=null;
       xlBook=null;
       xlsheet=null;

}

 


</script>  <link href="css/styles3.css" rel="stylesheet" type="text/css"/>
<title>ziyuanweihu</title>
</head>
<body>
  <form id="fors" method="post" action="/WebModule/admins/card/showcard.faces" enctype="application/x-www-form-urlencoded">

   

     

    <table id="fors:top" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td class="left"><img src="images/jiao1.gif" alt="" /></td>
<td class="topMiddle"></td>
<td class="right"><img src="images/jiao2.gif" alt="" /></td>
</tr>
</tbody>
</table>           

 

     
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td class="middleLeft"></td>
<td class="btstyle"><table id="fors:sort" border="0" cellpadding="0" cellspacing="0" style="valign:center" width="100%">
<tbody>
<tr>
<td class="btstyle"><input type="button" name="fors:_id7" value="&#29983;&#25104;excel&#25991;&#20214;" onclick="MakeExcel()" /><input type="submit" name="fors:_id8" value="&#36820;&#22238;" /></td>
</tr>
</tbody>
</table>
<table id="fors:data" border="1" cellpadding="0" cellspacing="1" width="100%">
<thead>
<tr>
<th scope="col"><span id="fors:data:headerText1">&#21345;&#21495;</span></th>
<th scope="col"><span id="fors:data:headerText2">&#23494;&#30721;</span></th>
<th scope="col"><span id="fors:data:headerText3">&#35745;&#36153;&#26041;&#24335;</span></th>
<th scope="col"><span id="fors:data:headerText4">&#26377;&#25928;&#22825;&#25968;</span></th>
<th scope="col">&#37329;&#39069;</th>
<th scope="col"><span id="fors:data:headerText6">&#25152;&#23646;&#26381;&#21153;&#39033;&#30446;</span></th>
<th scope="col"><span id="fors:data:headerText7">&#21457;&#21345;&#26102;&#38388;</span></th>
</tr>
</thead>
<tbody>
<tr>
<td>h000010010</td>
<td>543860</td>
<td>&#35745;&#28857;</td>
<td></td>
<td>2.0</td>
<td>&#27979;&#35797;&#39033;&#30446;</td>
<td>2006-06-23 10:14:40.843</td>
</tr>
<tr>
<td>h000010011</td>
<td>683352</td>
<td>&#35745;&#28857;</td>
<td></td>
<td>2.0</td>
<td>&#27979;&#35797;&#39033;&#30446;</td>
<td>2006-06-23 10:14:40.843</td>
</tr>
<tr>
<td>h000010012</td>
<td>433215</td>
<td>&#35745;&#28857;</td>
<td></td>
<td>2.0</td>
<td>&#27979;&#35797;&#39033;&#30446;</td>
<td>2006-06-23 10:14:40.843</td>
</tr>
<tr>
<td>h000010013</td>
<td>393899</td>
<td>&#35745;&#28857;</td>
<td></td>
<td>2.0</td>
<td>&#27979;&#35797;&#39033;&#30446;</td>
<td>2006-06-23 10:14:40.843</td>
</tr>
<tr>
<td>h000010014</td>
<td>031736</td>
<td>&#35745;&#28857;</td>
<td></td>
<td>2.0</td>
<td>&#27979;&#35797;&#39033;&#30446;</td>
<td>2006-06-23 10:14:40.843</td>
</tr>
<tr>
<td>h000010015</td>
<td>188600</td>
<td>&#35745;&#28857;</td>
<td></td>
<td>2.0</td>
<td>&#27979;&#35797;&#39033;&#30446;</td>
<td>2006-06-23 10:14:40.843</td>
</tr>
<tr>
<td>h000010016</td>
<td>363407</td>
<td>&#35745;&#28857;</td>
<td></td>
<td>2.0</td>
<td>&#27979;&#35797;&#39033;&#30446;</td>
<td>2006-06-23 10:14:40.843</td>
</tr>
<tr>
<td>h000010017</td>
<td>175315</td>
<td>&#35745;&#28857;</td>
<td></td>
<td>2.0</td>
<td>&#27979;&#35797;&#39033;&#30446;</td>
<td>2006-06-23 10:14:40.843</td>
</tr>
<tr>
<td>h000010018</td>
<td>354437</td>
<td>&#35745;&#28857;</td>
<td></td>
<td>2.0</td>
<td>&#27979;&#35797;&#39033;&#30446;</td>
<td>2006-06-23 10:14:40.843</td>
</tr>
<tr>
<td>h000010019</td>
<td>234750</td>
<td>&#35745;&#28857;</td>
<td></td>
<td>2.0</td>
<td>&#27979;&#35797;&#39033;&#30446;</td>
<td>2006-06-23 10:14:40.843</td>
</tr>
</tbody>
</table>
</td>
<td class="middleRight"></td>
</tr>
</tbody>
</table>

    <table id="fors:bottom" border="0" cellpadding="0" cellspacing="0" width="100%">
      <tbody>
        <tr>
          <td class="left">
            <img src="images/jiao3.gif" alt=""/>
          </td>
          <td class="bottomMiddle">          </td>
          <td class="right">
            <img src="images/jiao4.gif" alt=""/>
          </td>
        </tr>
      </tbody>
    </table>
 <input type="hidden" name="fors" value="fors" /></form>
</body>

</html>

相關(guān)文章

  • JavaScript創(chuàng)建對(duì)象的七種方式全面總結(jié)

    JavaScript創(chuàng)建對(duì)象的七種方式全面總結(jié)

    這篇文章主要介紹了JavaScript創(chuàng)建對(duì)象的七種方式,工廠模式,構(gòu)造函數(shù)模式,原型模式等分別在本文中做出了講解,具體操作步驟大家可查看下文的詳細(xì)講解,感興趣的小伙伴們可以參考一下。
    2017-08-08
  • 與Math.pow 相反的函數(shù)使用介紹

    與Math.pow 相反的函數(shù)使用介紹

    Math.pow函數(shù)想必大家都知道吧,本例介紹的是與其相反的函數(shù)
    2014-08-08
  • JavaScript的DOM事件詳解

    JavaScript的DOM事件詳解

    這篇文章主要為大家詳細(xì)介紹了JavaScript的DOM事件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助
    2022-02-02
  • 深入學(xué)習(xí)JavaScript中的Rest參數(shù)和參數(shù)默認(rèn)值

    深入學(xué)習(xí)JavaScript中的Rest參數(shù)和參數(shù)默認(rèn)值

    這篇文章主要介紹了深入學(xué)習(xí)JavaScript中的Rest參數(shù)和參數(shù)默認(rèn)值,是JS入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下
    2015-07-07
  • js的匿名函數(shù)使用介紹

    js的匿名函數(shù)使用介紹

    匿名函數(shù)的作用是創(chuàng)建一塊封閉區(qū)域,外面不能夠訪問(wèn)里面的變量和方法,下面為大家介紹下什么是匿名函數(shù)及其如何使用
    2013-12-12
  • js數(shù)組直接賦值的問(wèn)題(js數(shù)組的淺拷貝與深拷貝方法)

    js數(shù)組直接賦值的問(wèn)題(js數(shù)組的淺拷貝與深拷貝方法)

    JS數(shù)組在直接賦值時(shí)屬于數(shù)組的淺拷貝,新數(shù)組保存的是原數(shù)據(jù)的內(nèi)存地址,修改新數(shù)組或原數(shù)組其中一個(gè)數(shù)組,另一個(gè)數(shù)組也會(huì)相應(yīng)的變化,數(shù)組的直接賦值屬于數(shù)組的淺拷貝,JS存儲(chǔ)對(duì)象都是存內(nèi)存地址
    2022-10-10
  • 詳解Javascript ES6中的箭頭函數(shù)(Arrow Functions)

    詳解Javascript ES6中的箭頭函數(shù)(Arrow Functions)

    箭頭函數(shù),若有了解過(guò)coffeeScript的同學(xué),或許對(duì)此印象深刻,因?yàn)樗梢宰屨Z(yǔ)法省略不少,特別是對(duì)于回調(diào)函數(shù),會(huì)讓代碼更清晰簡(jiǎn)潔。下面讓我們一起來(lái)學(xué)習(xí)學(xué)習(xí)ES6中的箭頭函數(shù)。
    2016-08-08
  • JS數(shù)組(Array)處理函數(shù)整理

    JS數(shù)組(Array)處理函數(shù)整理

    這篇文章主要整理了一下JS數(shù)組(Array)處理函數(shù),常用的都匯總了一下,推薦給大家。
    2014-12-12
  • JavaScrip關(guān)于創(chuàng)建常量的知識(shí)點(diǎn)

    JavaScrip關(guān)于創(chuàng)建常量的知識(shí)點(diǎn)

    這篇文章主要介紹了JavaScrip創(chuàng)建常量的相關(guān)知識(shí)點(diǎn),幫助大家對(duì)JS更加深入的學(xué)習(xí),參考下吧。
    2017-12-12
  • JavaScript中this用法學(xué)習(xí)筆記

    JavaScript中this用法學(xué)習(xí)筆記

    在本篇文章里小編給大家分享了關(guān)于JavaScript中this用法學(xué)習(xí)筆記以及知識(shí)點(diǎn)總結(jié),有興趣的朋友們學(xué)習(xí)下。
    2019-03-03

最新評(píng)論