hi have this code that reads an excel file
how can i get it to read sheet2 in an excel file instead of sheet 1Code:Public Class ReadFromExcel Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click If ofdOpenFile.ShowDialog() = Windows.Forms.DialogResult.OK Then txtFileName.Text = ofdOpenFile.FileName End If End Sub Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click If Not String.IsNullOrEmpty(txtFileName.Text) Then Try btnClose.Enabled = False Dim OExcelHandler As New ExcelHandler() Dim ds As DataSet = OExcelHandler.GetDataFromExcel(txtFileName.Text.Trim()) If ds IsNot Nothing Then dgvExcelData.SelectionMode = DataGridViewSelectionMode.FullRowSelect dgvExcelData.EditMode = DataGridViewEditMode.EditProgrammatically dgvExcelData.DataSource = ds.Tables(0) End If Catch ex As Exception Finally btnClose.Enabled = True End Try End If End Sub




Reply With Quote