I have Browse button code, that when I browse to an Excel file, I then want to be able to select a particular worksheet for that file manually so I can then import that particular sheet into a Datagridview. I am trying to use either a combobox or a listbox.
My plans are to use the Browse button to populate a Textbox, then via that textbox, select a worksheet with the combobox or listbox, then import it to a Datagridview for review, before exporting it to a SQL Database table.
I have to code for the browse button, I can import the file to a dataviewgrid,and export it to SQL. But only if the Excel file has a Single "predefined" worksheet name. I need the worksheet selectable after the browse but before the Datagridview import. This is my Browse Button Code.I am guessing its to simplistic for the takes and must load the file first.
My plans are to use the Browse button to populate a Textbox, then via that textbox, select a worksheet with the combobox or listbox, then import it to a Datagridview for review, before exporting it to a SQL Database table.
I have to code for the browse button, I can import the file to a dataviewgrid,and export it to SQL. But only if the Excel file has a Single "predefined" worksheet name. I need the worksheet selectable after the browse but before the Datagridview import. This is my Browse Button Code.I am guessing its to simplistic for the takes and must load the file first.
VB.NET:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim fd As OpenFileDialog = New OpenFileDialog()
Dim strFileName As String
fd.Title = "Open File Dialog"
fd.InitialDirectory = "H:\COST ACCTG\Inventory\"
fd.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
fd.FilterIndex = 2
fd.RestoreDirectory = True
If fd.ShowDialog() = DialogResult.OK Then
strFileName = fd.FileName
End If
TextBox1.Text = strFileName
End Sub