标题:共享源码 vB编程VB源码 VB读取EXCEL工作薄某个表中数据 ADODB.Recordset
取消只看楼主
创造奇迹
Rank: 2
来 自:自动化软件开发定做
等 级:论坛游民
帖 子:8
专家分:40
注 册:2011-9-1
 问题点数:0 回复次数:0 
共享源码 vB编程VB源码 VB读取EXCEL工作薄某个表中数据 ADODB.Recordset
Private Sub Form_Load()  
Dim RS As ADODB.Recordset  
Set RS = GetExcelRs(App.Path & "\book1.xls")  
MsgBox RS.RecordCount  
MsgBox RS(0)  
RS(0) = Timer  
RS.Update  
RS.Close  
End Sub  
  
'┏〓〓〓〓〓〓〓〓〓 GetExcelRs,start 〓〓〓〓〓〓〓〓〓┓   
'[简介]:   
'VB读取EXCEL工作薄某个表中数据   
Function GetExcelRs(ByVal sFile As String, Optional ExcelSheetName As String = "sheet1", Optional ErrInfo As String) As ADODB.Recordset  
   '[mycode_id:2025],edittime:2011-9-7 下午 02:15:41   
   On Error GoTo Err  
   Dim RS As ADODB.Recordset  
   Set RS = New ADODB.Recordset  
   Dim ConnStr As String  
   ConnStr = "DRIVER=Microsoft Excel Driver (*.xls);" & "DBQ=" & sFile & ";ReadOnly=False"  
     
   RS.Open "SELECT * FROM [" & ExcelSheetName & "$]", ConnStr, 1, 3  
     
   Set GetExcelRs = RS  
   Set RS = Nothing  
     
   Exit Function  
   Err:  
   ErrInfo = Err.Description  
   MsgBox ErrInfo  
End Function  
'┗〓〓〓〓〓〓〓〓〓  GetExcelRs,end  〓〓〓〓〓〓〓〓〓┛  
搜索更多相关主题的帖子: 工作 编程 EXCEL start 
2011-09-07 20:32



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-349402-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.214828 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved