熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

VB連接Excel文件

2022-06-13   來源: .NET編程 

    Private Sub Command_Click()
    Dim conn As New ADODBConnection
    Dim rs As New ADODBRecordset

  connOpen Provider=MicrosoftJetOLEDB;Data Source=c:axls;Extended Properties=Excel ;HDR=YES;IMEX=
    rsOpen select * from [sheet$] conn adOpenForwardOnly adLockOptimistic

  Do While Not rsEOF
        Print rs()
        rsMoveNext
    Loop
    rsClose
    End Sub



    HDR和IMEX一定要配合使用HDR表示要把第一行作為數據還是作為列名作為數據用hdr=no作為列名用hdr=yes通過Imex=來把混合型作為文本型讀取避免null值


From:http://tw.wingwit.com/Article/program/net/201311/11943.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.