Results 1 to 2 of 2

Thread: Working with Excel file trough ADO.NET

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Location
    USA
    Posts
    3

    Question Working with Excel file trough ADO.NET

    This code works fine for reading cells from known Excel file:
    Dim MyCommand As OleDb.OleDbDataAdapter
    Dim MyConnection As OleDb.OleDbConnection
    Dim strCon As String
    strCon = "provider=Microsoft.Jet.OLEDB.4.0; " & _
    "data source=c:\MyData.xls" & _
    "Extended Properties=Excel 8.0;"
    MyConnection = New OleDb.OleDbConnection(strCon)
    ' Select the data from Sheet1 of the workbook.
    Dim strSelect As String
    strSelect = "select * from [Sheet1$]"
    MyCommand = New System.Data.OleDb.OleDbDataAdapter(strSelect, MyConnection)

    DS = New System.Data.DataSet


    MyCommand.Fill(DS)

    MyConnection.Close()
    Dim strCell00 As String
    strCell00 = CStr(DS.Tables(0).Rows(0).Item(0))
    End If

    My Q. is what if I don't know worksheet name, which is in this case "Sheet1$". How to get all worksheet names in Excel file?
    Last edited by Green; Jun 9th, 2004 at 05:10 PM.

  2. #2

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Location
    USA
    Posts
    3

    Cool

    If you want to know the answear, see it on gotDotNet.com in VB.NET section

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width