dddggg [原作]
函数 SwitchExcelInfo(xlsFileName)
变暗xlsStr
暗淡
调暗 i,j,k
昏暗 ExcelConn
昏暗的 Excel 文件
昏暗 objExcelApp
Dim objExcelBook
暗淡 bgColor
xlsStr =“”
ExeclFile = Server.MapPath(xlsFileName)
设置 objExcelApp = CreateObject("Excel.Application")
objExcelApp.退出
设置 objExcelApp = CreateObject("Excel.Application")
objExcelApp.退出
objExcelApp.DisplayAlerts = false '不显示警告
objExcelApp.Application.Visible = false '不显示界面
objExcelApp.WorkBooks.Open(ExeclFile)
设置 objExcelBook = objExcelApp.ActiveWorkBook
reDim arrSheets(objExcelBook.Sheets.Count)
对于 i=1 到 objExcelBook.Sheets.Count
arrSheets(i) = objExcelBook.Sheets(i).Name
下一个
objExcelApp.退出
设置 objExeclApp=无
'#################
'由www.downcodes.com提供支持
'#################
设置 ExcelConn = Server.CreateObject("ADODB.Connection")
ExcelDriver = "Driver={Microsoft Excel 驱动程序 (*.xls)};DBQ=" & ExeclFile
ExcelConn.Open ExcelDriver
设置 rs = Server.CreateObject("Adodb.RecordSet")
对于 i = 1 到 UBound(arrSheets)
Sql = "SELECT * FROM ["& arrSheets(i) &"$] "
'' 显示各工作表的名称
''xlsStr = xlsStr & "<br>"& arrSheets(i) &"<br>"
xlsStr = xlsStr & "<table cellpadding=1 width=""100%"" cellspacing=1 border=1 bordercolor='#000000' style='border-collapse:collapse;border:2pxsolid #000000'>"
rs.Open Sql,ExcelConn,1,1
k = 1
虽然不是 rs.eof
如果 k Mod 2 <> 0 则 bgColor = "bgColor=#E0E0E0" 否则 bgColor = ""
xlsStr = xlsStr & "<tr "& bgColor &">"
xlsStr = xlsStr & "<td>"& rs(0) &"</td>"
对于 j = 0 到 rs.Fields.Count-1
xlsStr = xlsStr & "<td>"& rs(j) &"</td>"
下一个
xlsStr = xlsStr & "</tr>"
rs.movenext
k = k + 1
文德
xlsStr = xlsStr & "</table><br>"
rs.关闭
下一个
ExcelConn.关闭
设置 ExcelConn = 无
SwitchExcelInfo = xlsStr
结束功能