hola etoy utilizando vb.net 2005 y me enlazo con excel 2007..
pero ultimamente me e tenido que enlazar con excel 2010 pero no logro hacerlo..
la principal razon de este tema es que en la consulta de excel 2007 los datos me los arroja en un datagridview pero en el nombre de las columnas me pone f1,f2,f3,f4,f5,.......fn
entonces nesecito editar esos nombres de columnas para ponerles el nombre que yo necesito..
el codigo que tengo es el siguiente:
Código:
Imports System.Data.OleDb
Public Class BUSCAR_BDD_EXCEL
    Dim DIRECCION, RANGO, hoja, r1, r2, columna As String
    'Dim  As Integer
    Dim cadenaConexionExcel As String
    Private Sub BUSCAR_BDD_EXCEL_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        hoja = "lista_cruzada_OI10_OI11"
        r1 = "A1"
        r2 = "AA32857"
        TextBox1.Text = "102143529"
        TextBox2.Text = hoja
        TextBox3.Text = r1
        TextBox4.Text = r2
        RANGO = hoja + "$" + r1 + ":" + r2
        'Dim VARIABLE As String
        Dim myStream As IO.Stream = Nothing
        Dim openFileDialog1 As New OpenFileDialog()

        openFileDialog1.InitialDirectory = "C:"
        openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
        openFileDialog1.FilterIndex = 2
        openFileDialog1.RestoreDirectory = True

        If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Try
                myStream = openFileDialog1.OpenFile()
                'Label1.Text = openFileDialog1.FileName
                DIRECCION = openFileDialog1.FileName
                Label1.Text = DIRECCION
                If (myStream IsNot Nothing) Then
                    ' Insert code to read the stream here.
                End If
            Catch Ex As Exception
                MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
            Finally
                ' Check this again, since we need to make sure we didn't throw an exception on open.
                If (myStream IsNot Nothing) Then
                    myStream.Close()
                End If
            End Try
        End If
        cadenaConexionExcel = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data source= " & openFileDialog1.FileName & ";" & _
        "Extended Properties='Excel 8.0;HDR=No;IMEX=1'"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            hoja = TextBox2.Text
            r1 = TextBox3.Text
            r2 = TextBox4.Text
            columna = TextBox5.Text
            'TextBox1.Text = "102238917-58"
            'TextBox2.Text = hoja
            'TextBox3.Text = r1
            'TextBox4.Text = r2
            RANGO = hoja + "$" + r1 + ":" + r2
            Dim cmd As New OleDbCommand()

            ' Seleccionamos todos las columnas de la hoja
            ' de Excel llamada 'Hoja1', donde el valor de 
            ' la columna IdCliente sea igual a 4300367.
            '
            cmd.CommandText = _
                "SELECT * FROM [" + RANGO + "] " & _
                "WHERE F18= ?"

            ' Añadimos el parámetro requerido.
            '
            cmd.Parameters.AddWithValue("", TextBox1.Text)

            ' Ejecutamos la consulta obteniendo un
            ' objeto DataTable.
            '
            Dim dt As DataTable = GetData(cmd, "DatosExcel")

            ' Mostramos el resultado en un control DataGridView.
            ' 
            DataGridView1.AutoGenerateColumns = False
            DataGridView1.DataSource = dt

        Catch ex As Exception
            ' Se ha producido un error
            MessageBox.Show("errorress" + ex.Message)

        End Try
    End Sub
    'Private cadenaConexionExcel As String = _
    '"Provider=Microsoft.Jet.OLEDB.4.0;" & _
    '"Data source= " & Me.openFileDialog1.FileName & ";" & _
    '"Extended Properties='Excel 8.0;HDR=No;IMEX=1'"
    Public Function GetData(ByVal cmd As OleDbCommand, ByVal tableName As String) As DataTable

        If (cmd Is Nothing) Then _
            Throw New ArgumentNullException()

        Try
            ' Configuramos una conexión con el origen de datos.
            '
            Using cnn As New OleDbConnection(cadenaConexionExcel)

                cmd.Connection = cnn

                Dim da As New OleDbDataAdapter(cmd)

                If (String.IsNullOrEmpty(tableName)) Then _
                    tableName = "NewDataTable"

                Dim dt As New DataTable(tableName)

                da.Fill(dt)

                Return dt

            End Using

        Catch ex As Exception
            Throw

        End Try

    End Function

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        
    End Sub
End Class