Dim OpenFileDialog1 As New OpenFileDialog() Dim constr As String 'Dim con As OleDb.OleDbConnection Dim con As OleDbConnection Try OpenFileDialog1.Filter = "Excel Files | *.xlsx; *.xls; *.xlsm;" If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Me.txtOpen.Text = OpenFileDialog1.FileName constr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" + txtOpen.Text + ";Extended Properties = Excel 8.0;HDR=Yes;IMEX=1" 'constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + txtOpen.Text + ";Excel 12.0 Xml;HDR=YES" con = New OleDbConnection(constr) con.Open() cboSheet.DataSource = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing) cboSheet.DisplayMember = "TABLE_NAME" cboSheet.ValueMember = "TABLE_NAME" End If Catch ex As Exception MessageBox.Show(ex.Message) End Try
Microsoft.Jet.OLEDB.4.0
.xlsx
Microsoft.ACE.OLEDB.12
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)