码迷,mamicode.com
首页 > 其他好文 > 详细

【VB6笔记-01】 读取Excel绑定到DataGrid

时间:2014-05-16 05:24:22      阅读:302      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   c   java   

bubuko.com,布布扣
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
bubuko.com,布布扣

 

【VB6笔记-01】 读取Excel绑定到DataGrid,布布扣,bubuko.com

【VB6笔记-01】 读取Excel绑定到DataGrid

标签:style   blog   class   code   c   java   

原文地址:http://www.cnblogs.com/allen0118/p/3726388.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!