How to find row index and column index be cell value only?
I have no column name, column number, or anything else except cell value.
I want to get the row index of “Total” by using string “Total”, expected result is 12
and get the column of “Amount” by using string “Amount”, expected result is “C”
Below is the sample of the excel files, it is dynamic that “Amount” might be in column D, or E, etc in other excel
Prepare an empty datatatable with build datatable and configure the following columns:
search (string) ,ridx (int32), cidx (int32) - dtReport
Prepare a variable
arrSearchKeys | String Array = new String(){“AMOUNT”, “TOTAL”}
Assign Activity
dtReport =
(From c in Enumerable.Range(0, YourDataTableVar.Columns.Count)
From s in arrSearchKeys
Let i = YourDataTableVar.AsEnumerable.ToList.FindIndex(Function (d) d(c).Tostring.ToUpper.Trim.Equals(s))
Where i > -1
Let ra = new Object(){s, i, c}
Select r = dtReport.Rows.Add(ra)).CopyToDataTable