使用Excel 2016作为ASP Classic中的数据库

时间:2017-01-13 14:48:10

标签: asp-classic odbc dsn excel-2016

有谁知道如何在网页中显示Excel 2016文件的内容?

我无法弄清楚如何从网页打开连接以及我可能需要安装哪些驱动程序才能打开ODBC或DSN连接。

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

在使用了几个小时之后我就开始工作了。

以下是我如何阅读数据

<%
Dim Conn, Sql, rs
Set Conn = Server.createobject("ADODB.Connection")
Conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\inetpub\wwwroot\test\test.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1"";"

    ' Ark1 is danish for Sheet1
    Sql = "select * from [Ark1$]"

set rs = Conn.Execute(Sql)

do while not rs.eof or rs.bof
    response.write rs("test") & "<br>" & vbCrLf
    rs.movenext
loop

    Conn.CLose
Set Conn = nothing
%>

希望这可能有助于其他人。

相关问题