I am reading an Excel file using ExcelDataReader
Dim entireExcel As DataTableCollection
Using ofd As OpenFileDialog = New OpenFileDialog() With {.Filter = "Excel Workbook|*.xlsx|Excel 97-2003 Workbook|*.xls"}
If ofd.ShowDialog() = DialogResult.OK Then
txtFileName.Text = ofd.FileName
Using stream = File.OpenRead(ofd.FileName)
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance)
Dim reader As IExcelDataReader = ExcelReaderFactory.CreateReader(stream)
entireExcel = reader.AsDataSet(New ExcelDataSetConfiguration() With {
.ConfigureDataTable = Function(__) New ExcelDataTableConfiguration() With {
.UseHeaderRow = True}}).Tables
End Using
End If
End Using
It all works fine, with one exception: The column names in the sheets are not the real ones in Excel. If the column is a duplicate of a column to the left, it adds _1, _2, etc., to the name. If the column name is missing, it creates a name Column0, Column1, Column2, etc.
How can I get the real names, or how can I prevent changing them?