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 贺挺 阅读(653) 评论(0)  编辑  收藏 所属分类: js

只有注册用户登录后才能发表评论。


网站导航: