Friday, 23 August 2013

Excel Find column number of a column thru column name and access data of all rows

Excel Find column number of a column thru column name and access data of
all rows

I have created an Excel sheet (xls or xlsx) dynamically who has several
cols 50+. Most of the cols have a single row data. Some have multiple rows
data. Their are few same col names also. My concern is I want to access
cols of multiple rows whose col names are same. For eg : Placement Header
Val1 Val2 Vall3 Header Val1 Val2 Val3
TRUE FIP 1 2 3 SI A 4 5 6 Sheer 7 8 9 SI B 5 2 6 Cont 6 5 4 ----- 1 List
---------- ----------- 2 List -------
1 List & 2List data belongs to same class and is both are added with same
column names.
I am using OLEDB to read data. My class contains properties (Header, Val1,
Val2, Val3). To read data, I iterate thru each property of class and store
data. But with this case, I have multiple tables with same headers.
Is their a way, that I can find column number of col "Placement" and then
seek next 3 cols in and store all 3 rows data in a list.
Or any other alternative method to access the columns of this type and
store them in different Lists object.
Any help is highly appreciative. I am stuck here and am in hurry.

No comments:

Post a Comment