I have an excel file as above. I want to fetch data present in front of each label (Name, Class, Gender) and data present in column (Subject, Marks, OutOff). There are no column headers in the excel sheet. Can we use the LINQ query to fetch data? If yes, Can you please provide me the query?
If you excel file is fixed and you want to access the values
Check as below
You can set to another datatable too, Check below for your reference
Hope this helps you
Thanks
Excel is not fixed. In some excel you will find above mentioned column/labels and in some excel you will not find it or may be they are placed at different location. Also I want to write this data into another excel file which will be having column headers with same name as label/columns present in this excel file.
read excel file as DT1 without headers and then for each row, when column = key header then write row to new DT2. Use DT2 to do other stuff.
Need to use for each and lots of if statement with this approach as columns are not fixed. coulmn can be present at any location in excel file. (for e.g.in one file “Subject” heading and its data will be present in column A and in another file it will be present in column B). Can we use linq query here?
Also, can we make 8th row present in excel file to act as column header?