vbscript生成EXCEL
<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>