dddggg [原作]
Función SwitchExcelInfo(xlsFileName)
Dim xlsStr
rs tenues
tenue i,j,k
Dim ExcelConn
Atenuar archivo Excel
Dim objExcelApp
Objeto tenueExcelBook
Dim bgColor
xlsStr = ""
ExeclFile = Server.MapPath(xlsFileName)
Establecer objExcelApp = CreateObject("Excel.Application")
objExcelApp.Salir
Establecer objExcelApp = CreateObject("Excel.Application")
objExcelApp.Salir
objExcelApp.DisplayAlerts = false '不显示警告
objExcelApp.Application.Visible = false '不显示界面
objExcelApp.WorkBooks.Open(ExeclFile)
establecer objExcelBook = objExcelApp.ActiveWorkBook
reDim arrSheets(objExcelBook.Sheets.Count)
Para i=1 a objExcelBook.Sheets.Count
arrSheets(i) = objExcelBook.Sheets(i).Nombre
Próximo
objExcelApp.Salir
Establecer objExeclApp = nada
'#################
'Poder por www.downcodes.com
'#################
Establecer ExcelConn = Server.CreateObject ("ADODB.Connection")
ExcelDriver = "Controlador={Controlador de Microsoft Excel (*.xls)};DBQ=" & ExeclFile
ExcelConn.Abrir ExcelDriver
Establecer rs = Server.CreateObject("Adodb.RecordSet")
Para i = 1 a UBound(arrSheets)
Sql = "SELECCIONAR * DESDE ["& 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
Mientras no sea rs.eof
Si k Mod 2 <> 0 Entonces bgColor = "bgColor=#E0E0E0" De lo contrario bgColor = ""
xlsStr = xlsStr & "<tr "& bgColor &">"
xlsStr = xlsStr & "<td>"& rs(0) &"</td>"
Para j = 0 a rs.Fields.Count-1
xlsStr = xlsStr & "<td>"& rs(j) &"</td>"
Próximo
xlsStr = xlsStr & "</tr>"
rs.movenext
k = k + 1
Encaminarse a
xlsStr = xlsStr & "</table><br>"
rs.Cerrar
Próximo
ExcelConn.Cerrar
Establecer ExcelConn = Nada
SwitchExcelInfo = xlsStr
Función final