dddggg [原作]
Function SwitchExcelInfo(xlsFileName)
Dim xlsStr
Dim rs
Dim i,j,k
Dimmen Sie ExcelConn
ExcelFile dimmen
Dimmen Sie objExcelApp
Dim objExcelBook
Dim bgColor
xlsStr = ""
ExeclFile = Server.MapPath(xlsFileName)
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Quit
Setze objExcelApp = CreateObject("Excel.Application")
objExcelApp.Quit
objExcelApp.DisplayAlerts = false 'Es wird nicht angezeigt
objExcelApp.Application.Visible = false
objExcelApp.WorkBooks.Open(ExeclFile)
set objExcelBook = objExcelApp.ActiveWorkBook
reDim arrSheets(objExcelBook.Sheets.Count)
Für i=1 bis objExcelBook.Sheets.Count
arrSheets(i) = objExcelBook.Sheets(i).Name
Nächste
objExcelApp.Quit
Setze objExeclApp=nothing
'#################
'Power By www.downcodes.com
'#################
Setze ExcelConn = Server.CreateObject("ADODB.Connection")
ExcelDriver = "Driver={Microsoft Excel Driver (*.xls)};DBQ=" & ExeclFile
ExcelConn.ExcelDriver öffnen
Setze rs = Server.CreateObject("Adodb.RecordSet")
Für i = 1 bis UBound(arrSheets)
Sql = "SELECT * FROM ["& arrSheets(i) &"$] "
''显示各工作表的名称
''xlsStr = xlsStr & "<br>"& arrSheets(i) &"<br>"
xlsStr = xlsStr & "<table cellpadding=1 width=""100%"" cellpacing=1 border=1 bordercolor='#000000' style='border-collapse:collapse;border:2px solid #000000'>"
rs.Open Sql,ExcelConn,1,1
k = 1
Während nicht rs.eof
Wenn k Mod 2 <> 0, dann bgColor = "bgColor=#E0E0E0" Sonst bgColor = ""
xlsStr = xlsStr & "<tr "& bgColor &">"
xlsStr = xlsStr & "<td>"& rs(0) &"</td>"
Für j = 0 bis rs.Fields.Count-1
xlsStr = xlsStr & "<td>"& rs(j) &"</td>"
Nächste
xlsStr = xlsStr & "</tr>"
rs.movenext
k = k + 1
Wend
xlsStr = xlsStr & "</table><br>"
rs.Schließen
Nächste
ExcelConn.Close
Setzen Sie ExcelConn = Nothing
SwitchExcelInfo = xlsStr
Funktion beenden