Este código resolveu meu problema:
Me.dataGridView1.Columns ("CustomerID"). Visible = False
Existe uma maneira de adicionar mais de um intervalo de dados do Excel ao Visual Basic? Eu consegui importar as células A6 para B260 em um datagrid, mas também quero as colunas E6-E260 e G6-G260. (selectedNOD é a planilha selecionada)
Dim selectedNOD As String
selectedNOD = ListNOD.SelectedItem
Try
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim dataSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim path As String = "NOD.xlsx"
MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [" + selectedNOD + "$A6:B260]", MyConnection)
dataSet = New System.Data.DataSet
MyCommand.Fill(dataSet)
DataGridView1.DataSource = dataSet.Tables(0)
MyConnection.Close()
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
Este código resolveu meu problema:
Me.dataGridView1.Columns ("CustomerID"). Visible = False