DDDGGG [Original]
Function Switchexcelinfo (Xlsfilename)
Dim Xlsstr
Dim RS
Dim i,j,k
Dim Excelconn
Dim Excelfile
Dim Objexcelapp
Dim Objexcelbook
Dim bgcolor
Xlsstr = ""
Execlfile = Server.MapPath (xlsfilename)
Set Objexcelapp = CreateObject ("Excel.Application")
Objexcelapp.quit
Set Objexcelapp = CreateObject ("Excel.Application")
Objexcelapp.quit
Objexcelapp.displayalerts = False ' does not show warning
ObjExcelApp.Application.Visible = False ' does not display interface
ObjExcelApp.WorkBooks.Open (Execlfile)
Set Objexcelbook = Objexcelapp.activeworkbook
ReDim Arrsheets (ObjExcelBook.Sheets.Count)
For I=1 to ObjExcelBook.Sheets.Count
Arrsheets (i) = Objexcelbook.sheets (i). Name
Next
Objexcelapp.quit
Set objexeclapp=nothing
'#################
' Power by www.knowsky.com
'#################
Set excelconn = Server.CreateObject ("ADODB. Connection ")
Exceldriver = "Driver={microsoft Excel Driver (*.xls)};D bq=" & Execlfile
Excelconn.open Exceldriver
Set rs = Server.CreateObject ("Adodb.recordset")
For i = 1 to UBound (arrsheets)
SQL = "SELECT * FROM [" & Arrsheets (i) & "$]"
' Show the names of each sheet
' Xlsstr = xlsstr & '
"& Arrsheets (i) &"
"
Xlsstr = Xlsstr & "
"
Rs. Open sql,excelconn,1,1
K = 1
While not rs.eof
If k Mod 2 <> 0 Then bgcolor = "bgcolor= #E0E0E0" Else bgcolor = ""
Xlsstr = xlsstr & ""
Xlsstr = xlsstr & ""
For j = 0 to Rs. Fields.count-1
Xlsstr = xlsstr & ""
Next
Xlsstr = xlsstr & ""
Rs.movenext
K = k + 1
Wend
Xlsstr = Xlsstr & "
| "& RS (0) &" |
"& RS (j) &" |
"
Rs. Close
Next
Excelconn.close
Set Excelconn = Nothing
Switchexcelinfo = Xlsstr
End Function