3 回答
TA贡献2019条经验 获得超9个赞
vbs读取excel脚本倒是好说,但你的程序明显在vb与vba之间,恕我看不懂。 给你个例子参考下:
' Read an Excel Spreadsheet
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
("C:\Scripts\New_users.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
Wscript.Echo "CN: " & objExcel.Cells(intRow, 1).Value
Wscript.Echo "sAMAccountName: " & objExcel.Cells(intRow, 2).Value
Wscript.Echo "GivenName: " & objExcel.Cells(intRow, 3).Value
Wscript.Echo "LastName: " & objExcel.Cells(intRow, 4).Value
intRow = intRow + 1
Loop
objExcel.Quit
TA贡献1712条经验 获得超3个赞
<%
set conn=Server.CreateObject("Adodb.Connection")
Driver = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};"
DBPath = "DBQ=" & Server.MapPath("zhenhe.xls") 'zhenhe.xls改为你的文件名
conn.open Driver&DBPath
sql="select * from [Sheet1$]" '[Sheet1$]表单名
set rs=conn.execute(sql)
for i=0 to Rs.Fields.Count-1
response.write rs(i).name&""
abcde=rs(0).name&""
next
response.write "<br>"
response.write "<br>"
do while not rs.eof
for i=0 to Rs.Fields.Count-1
response.write rs(i).value&""
next
response.write "<br>"
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<%=abcde%>
添加回答
举报