首页 > 代码库 > 【VB6笔记-01】 读取Excel绑定到DataGrid
【VB6笔记-01】 读取Excel绑定到DataGrid
Private Sub cmdOpen_Click() CommonDialog1.Filter = "Excel???t(*.xlsx)|*.xlsx" CommonDialog1.DialogTitle = "????" CommonDialog1.ShowOpen Me.txtFilePath.Text = CommonDialog1.FileName Dim DBconn As ADODB.Connection Dim strSQL As String Dim RS As ADODB.Recordset Set DBconn = New ADODB.Connection Set RS = New ADODB.Recordset DBconn.CursorLocation = adUseClient strSQL = "SELECT * FROM [Sheet1$]" DBconn.Open "provider=microsoft.ace.oledb.12.0;extended properties=‘Excel 12.0 Xml; imex=1‘; data source=" & Me.txtFilePath.Text RS.Open strSQL, DBconn, adOpenDynamic, adLockOptimistic Set dgList.DataSource = RS dgList.AllowUpdate = True End Sub
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。