ddgggg [原作]
Fungsi SwitchExcelInfo(xlsFileName)
Redupkan xlsStr
Redupkan rs
Redupkan aku,j,k
Redupkan ExcelConn
Redupkan File Excel
Redupkan objekExcelApp
Redupkan objekExcelBook
Redupkan bgColor
xlsStr = ""
ExeclFile = Server.MapPath(xlsFileName)
Setel objExcelApp = CreateObject("Excel.Application")
objExcelApp.Keluar
Setel objExcelApp = CreateObject("Excel.Application")
objExcelApp.Keluar
objExcelApp.DisplayAlerts = false '不显示警告
objExcelApp.Application.Visible = false '不显示界面
objExcelApp.Buku Kerja.Buka(File Execl)
atur objExcelBook = objExcelApp.ActiveWorkBook
redimkan arrSheets(objExcelBook.Sheets.Count)
Untuk i=1 hingga objExcelBook.Sheets.Count
arrSheets(i) = objExcelBook.Sheets(i).Nama
Berikutnya
objExcelApp.Keluar
Setel objExeclApp=tidak ada
'#################
'Kekuatan Oleh www.downcodes.com
'#################
Atur ExcelConn = Server.CreateObject("ADODB.Connection")
ExcelDriver = "Driver={Driver Microsoft Excel (*.xls)};DBQ=" & ExeclFile
ExcelConn.Buka ExcelDriver
Setel rs = Server.CreateObject("Adodb.RecordSet")
Untuk i = 1 hingga UBound(arrSheets)
Sql = "PILIH * DARI ["& 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:2px solid #000000'>"
rs.Buka Sql,ExcelConn,1,1
k = 1
Meskipun Bukan rs.eof
Jika k Mod 2 <> 0 Maka bgColor = "bgColor=#E0E0E0" Else bgColor = ""
xlsStr = xlsStr & "<tr "& bgColor &">"
xlsStr = xlsStr & "<td>"& rs(0) &"</td>"
Untuk j = 0 sampai rs.Fields.Count-1
xlsStr = xlsStr & "<td>"& rs(j) &"</td>"
Berikutnya
xlsStr = xlsStr & "</tr>"
rs.movenext
k = k + 1
Pergi ke
xlsStr = xlsStr & "</tabel><br>"
rs.Tutup
Berikutnya
ExcelConn.Tutup
Setel ExcelConn = Tidak Ada
SwitchExcelInfo = xlsStr
Fungsi Akhir