heting

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            40 隨筆 :: 9 文章 :: 45 評論 :: 0 Trackbacks
          <html><head>

          <script language="javascript" type="text/javascript">
                
          function MakeExcel() {

                  
          var i, j, n;

                  
          try {

                    
          var xls = new ActiveXObject("Excel.Application");

                  }


                  
          catch(e) {

                    alert( 
          "要生成該表,您必須安裝Excel電子表格軟件,同時瀏覽器須使用“ActiveX 控件”,您的瀏覽器須允許執行控件。請點擊【幫助】了解瀏覽器設置方法!");

                      
          return "";

                  }


                  xls.visible 
          =true// 設置excel為可見

                  
          var xlBook = xls.Workbooks.Add;

                  
          var xlsheet = xlBook.Worksheets(1);

               
                  xlsheet.Cells(
          2,1).Value = "卡號";

                  xlsheet.Cells(
          2,2).Value = "密碼";

                  xlsheet.Cells(
          2,3).Value = "計費方式";

                  xlsheet.Cells(
          2,4).Value = "有效天數";

                  xlsheet.Cells(
          2,5).Value = "金額";


                  xlsheet.Range(xlsheet.Cells(
          1,1),xlsheet.Cells(1,7)).mergecells=true;

                  xlsheet.Range(xlsheet.Cells(
          1,1),xlsheet.Cells(1,7)).value="發卡記錄";
                  
                 
                  
                  xlBook.SaveAs(
          "C:\\TEST.XLS");
                  
                  
          // 用 Application 對象用 Quit 方法關閉 Excel。
                  
                  xlBook.Application.Quit();

                  xls
          =null;

                  xlBook
          =null;

                  xlsheet
          =null;

                }


              
              
          </script>
          </head><body><input type='button' value="生成" onclick='MakeExcel()'></body></html>


          posted on 2009-11-07 12:17 賀挺 閱讀(679) 評論(0)  編輯  收藏 所屬分類: js

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 卫辉市| 常山县| 宁陕县| 江川县| 井陉县| 仪征市| 永安市| 辽宁省| 安丘市| 明光市| 柳河县| 盐池县| 贵溪市| 曲沃县| 巴南区| 宜兴市| 伊吾县| 铜陵市| 台南县| 昌邑市| 巴中市| 沁水县| 遂川县| 玉林市| 定边县| 黑山县| 阿城市| 东海县| 胶南市| 白城市| 阜新市| 海原县| 和硕县| 平武县| 沅陵县| 赣州市| 杭锦旗| 青河县| 衡山县| 通榆县| 荥经县|