Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
below is the code I am using to read the column names from an excel
worksheet... its working fine except in two instances: 1) if i read from an empty worksheet then it returns F1 - how can i make it not return anything 2) if i have multiple columns with different "types" of names then it returns the generic (F1,F2,F3....) for example if i have 4 colums names: "First Name", "Last Name", "1/1/2009", "City" if these are the four coumn names(first row of the worksheet), then it returns: "First Name", "Last Name", "F3", "City" notice the F3 instead of the 1/1/2009 - how can i avoid this? The user selects the excel worksheet to read from hence I dont know how many columns are there and what kind of datatype is the column name... Dim sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dataSource & ";Extended Properties=""Excel 8.0;HDR=YES;IMEX=1""" Dim dt As New DataTable Dim da As New OleDb.OleDbDataAdapter Dim conn As New OleDb.OleDbConnection(sConnectionString) Dim columnList As New List(Of String) da = New OleDb.OleDbDataAdapter("Select top 1 * from [" & worksheetName & "]", conn) da.Fill(dt) For Each dc As DataColumn In dt.Columns columnList.Add(dc.ColumnName) Next |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Reading Data from an Excel Sheet | Excel Programming | |||
Reading data arrays from multiple data files in excel | Excel Discussion (Misc queries) | |||
Reading data from PPT and purge data to Excel and image | Excel Programming | |||
Reading data from excel | Excel Programming | |||
Reading excel data into another aplication | Excel Programming |