如何用ASP读取Excel文件
展开全部
Dim Conn,Driver,DBPath,Rs
'建立Excel的Connection对象
Set Conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Excel Driver (*.xls)};"
DBPath = "DBQ=" & Server.MapPath( "test.xls" )
'调用Open方法打开数据库
Conn.Open Driver & DBPath
'设置DSN连接方式
'Conn.Open "Dsn=test"
'注意 表名一定要按照 "[表名$]" 格式书写
Sql="Select * From [Sheet1$] where 序号=0"
Set Rs=Conn.Execute(Sql)
IF Rs.Eof And Rs.Bof Then
Response.write "数据未找到!!"
Else
Do While Not Rs.EOF
Response.write Rs("书名")
Rs.MoveNext
Loop
End IF
'建立Excel的Connection对象
Set Conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Excel Driver (*.xls)};"
DBPath = "DBQ=" & Server.MapPath( "test.xls" )
'调用Open方法打开数据库
Conn.Open Driver & DBPath
'设置DSN连接方式
'Conn.Open "Dsn=test"
'注意 表名一定要按照 "[表名$]" 格式书写
Sql="Select * From [Sheet1$] where 序号=0"
Set Rs=Conn.Execute(Sql)
IF Rs.Eof And Rs.Bof Then
Response.write "数据未找到!!"
Else
Do While Not Rs.EOF
Response.write Rs("书名")
Rs.MoveNext
Loop
End IF
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询