1<PRE lang=cs id=pre1 style="MARGIN-TOP: 0px" nd="24"><script language="vbscript">
2
3 Function Export(objToExport)
4
5 ON ERROR RESUME NEXT
6 DIM sHTML, oExcel, fso, filePath
7
8 sHTML = document.all(objToExport).outerHTML
9
10 SET fso = CreateObject("Scripting.FileSystemObject")
11 filePath = fso.GetSpecialFolder(2) & "\MyExportedExcel.xls"
12 fso.CreateTextFile(filePath).Write(sHTML)
13
14 DIM i
15 SET i = 0
16
17 DO WHILE err.number > 0
18 err.Clear()
19 filePath = fso.GetSpecialFolder(2) &
20 "\MyExportedExcel" & i & ".xls"
21 fso.CreateTextFile(filePath).Write(sHTML)
22
23 i = i + 1
24 LOOP
25
26 SET oExcel = CreateObject("Excel.Application")
27 IF err.number>0 OR oExcel =NULL THEN
28 msgbox("You need to have Excel Installed and Active-X
29 Components Enabled on your System.")
30 EXIT FUNCTION
31 END IF
32
33 oExcel.Workbooks.open(filePath)
34 oExcel.Workbooks(1).WorkSheets(1).Name = "My Excel Data"
35 oExcel.Visible = true
36 Set fso = Nothing
37
38 End Function
39
40</script>
41</PRE>
2
3 Function Export(objToExport)
4
5 ON ERROR RESUME NEXT
6 DIM sHTML, oExcel, fso, filePath
7
8 sHTML = document.all(objToExport).outerHTML
9
10 SET fso = CreateObject("Scripting.FileSystemObject")
11 filePath = fso.GetSpecialFolder(2) & "\MyExportedExcel.xls"
12 fso.CreateTextFile(filePath).Write(sHTML)
13
14 DIM i
15 SET i = 0
16
17 DO WHILE err.number > 0
18 err.Clear()
19 filePath = fso.GetSpecialFolder(2) &
20 "\MyExportedExcel" & i & ".xls"
21 fso.CreateTextFile(filePath).Write(sHTML)
22
23 i = i + 1
24 LOOP
25
26 SET oExcel = CreateObject("Excel.Application")
27 IF err.number>0 OR oExcel =NULL THEN
28 msgbox("You need to have Excel Installed and Active-X
29 Components Enabled on your System.")
30 EXIT FUNCTION
31 END IF
32
33 oExcel.Workbooks.open(filePath)
34 oExcel.Workbooks(1).WorkSheets(1).Name = "My Excel Data"
35 oExcel.Visible = true
36 Set fso = Nothing
37
38 End Function
39
40</script>
41</PRE>
为啥看不到呢?