Hi, I have a requirement where I have to read the course name “commerce” (the name is dynamic) from the given excel sheet. How to read the course name from excel without opening the excel sheet(Cell Address is constant). And also I have to read the table from the given excel into Datatable.
I dont know the exact Cell adresses. these are fixed, but dont know the exact address.
I know only it sheet has "course " word, based on this I have to fetch the course name and also the table
You could read the entier Excel document as a DataTable, then go through each row until you find the row where the value of the first item is the word “COURSE”. (e.g. currentRow(0).ToString = “COURSE”). Then you can fetch the course name from column C (e.g. currentRow(2).ToString).
first if you filter on course in first column then you will get only single row
And if you already know the column in which the course name is present then we can use Filtereddt.Rows(0)(3).ToString to get the course name(Assumign course name is in D column or the fourth column)
If it is not static then use a for loop on dt.Columns and check each column for value and get the value