扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
Dim myOleDbConnection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=c:\test.xls;" & _ "Extended Properties=""Excel 8.0;""") Dim myOleDbCommand As OleDbCommand = New OleDbCommand("SELECT * FROM [Sheet1$]",myOleDbConnection) '如果你想读出Sheet2的内容 ,把Sheet1$改成Sheet2$即可 Dim myData As OledbDataAdapter= New OledbDataAdapter(myOleDbCommand) |
Dim myDataset As New DataSet() myData.Fill(myDataset) '完成从OledbDataAdapter对象到DataSet的转换 DataGrid1.DataSource = myDataset.Tables(0).DefaultView DataGrid1.DataBind() '完成数据帮定,显示数据 |
<%@ Page Language="VB" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.Oledb" %> <script language="VB" runat="server"> Sub Page_Load(sender As Object, e As EventArgs) Dim myDataset As New DataSet() Dim myOleDbConnection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=c:\2.xls;" & _ "Extended Properties=""Excel 8.0;""") Dim myOleDbCommand As OleDbCommand = New OleDbCommand("SELECT * FROM [Sheet1$]",myOleDbConnection) Dim myData As OledbDataAdapter= New OledbDataAdapter(myOleDbCommand) myData.Fill(myDataset) DataGrid1.DataSource = myDataset.Tables(0).DefaultView DataGrid1.DataBind() End Sub </script> <html> <head></head> <body> <asp:Label id="L1" runat="server">读取C盘根目录下的test.xls文件,并以DataGrid的形式显示出来</asp:label> <asp:DataGrid id=DataGrid1 runat="server"/> </body> </html> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者