dddggg [原作]
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 '不显示警告
objexcelapp.application.visible = false '不显示界面
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
'#################
set excelconn = server.createobject(adodb.connection)
exceldriver = driver={microsoft excel driver (*.xls)};dbq= & execlfile
excelconn.open exceldriver
set rs = server.createobject(adodb.recordset)
for i = 1 to ubound(arrsheets)
sql = select * from [& arrsheets(i) &$]
''显示各工作表的名称
''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
更多信息请查看IT技术专栏