欢迎光临
我们一直在努力

建站超值云服务器,限时71元/月

this code was written in response to a message posted on one of charles carrolls asp.net lists. you can sign up for one or all of the lists here.this page provides a simple example of how to query an excel spreadsheet from an asp.net page using vb.net.

code:

<%@ page language="vb" %>
<%@ import namespace="system.data" %>
<%@ import namespace="system.data.oledb" %>
<html>
<script language="vb" runat="server">
sub page_load(sender as object, e as eventargs)
    dim mydataset as new dataset()
    
    dim strconn as string = "provider=microsoft.jet.oledb.4.0;" & _
                       "data source=" & replace(server.mappath("."), "\", "\\") & "\\exceltest.xls;" & _
                "extended properties=""excel 8.0;"""

    you must use the $ after the object you reference in the spreadsheet
    dim myoledbdataadapter as new oledbdataadapter("select * from [sheet1$]", strconn)
    myoledbdataadapter.fill(mydataset)

    datagrid1.datasource = mydataset.tables(0).defaultview
        datagrid1.databind()        
end sub
</script>
</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 »
分享到: 更多 (0)

相关推荐

  • 暂无文章