首    页 界面/窗口 网络/通讯 数据库 组件开发 图像/多媒体 NET/Web 其它技术 源码下载 资料下载 软件共享 软件外包 曲艺杂谈
栏目导航:  首    页  |  NET/Web  |  VBScript 

VBScript生成EXCEL


原作者:不详    源出处:CSDN    发布者:施昌权    发布类型:转载    发布日期:2008-11-28

 

<SCRIPT LANGUAGE="VBScript">
<!--
  Sub PrintList(table,title)
   '复制到剪贴板
   'document.execCommand "copy"
   '导出到Excel
   dim app, book, sheet
   err.number = 0
   on error resume next
   set app = CreateObject("Excel.Application")
   app.Visible = True
   if err.number <> 0 then
    msgbox "请确认您已经正确安装Microsoft Excel 2000以上版本,并正确配置浏览器安全设置。"
    exit sub
   end if
   Set book = app.Workbooks.Add
   Set sheet = book.ActiveSheet
   If sheet Is Nothing Then
    Set sheet = book.Sheets.Add
   End If
   sheet.Cells.Select
   app.Selection.NumberFormatLocal = "@"
   dim i, j
   set titlerow = title.rows(0)
   sheet.Cells(1,1) = titlerow.cells(0).innerText
   for i = 0 to table.rows.length - 1
    set row = table.rows(i)
    for j = 0 to row.cells.length - 1
     sheet.Cells(i + 2, j + 1) = row.cells(j).innerText
    next
   next
   rowCount = table.rows.length
   colCount = table.rows(0).cells.length
   '自动调整行高列宽
   app.Range(sheet.Cells(2, 1), sheet.Cells(rowCount, colCount)).Select
   app.Selection.Rows.AutoFit
   app.Selection.Columns.AutoFit
   app.Selection.Rows.AutoFit
   '设置表头格式
   app.Range(sheet.Cells(1, 1), sheet.Cells(1, colCount)).Select  
   app.Selection.Merge
   app.Range(sheet.Cells(1, 1), sheet.Cells(1, colCount)).Select
   app.Selection.Font.Bold = True
   app.Selection.Font.Size = 15  
   app.Range(sheet.Cells(1, 1), sheet.Cells(1, colCount)).HorizontalAlignment = xlCenter
   sheet.PrintOut
  End Sub
-->
</SCRIPT>


关于我们 版权声明 广告服务 联系我们 友情链接 加入收藏
站长:施昌权    Email:scq2099yt@163.com    MSN:scq2099yt@live.cn    QQ:14046300    本站QQ群:67202409
Copyright © 2008     卓为VC(www.joyvc.cn)    All Rights Reserved    建议分辨率 1024×768
本站由施昌权制作维护
京ICP备09012297号