Find text into Excel File

I am trying finding an determinate text into a excel file for example
My word is Q0192928338

and my excel has the following rows


I need to search my text in order to get its row and column number.


If you Read Range your table to a datatable variable, there are a few ways to grab the datarow that equals that value using LINQ or Lambda expressions and super fast and easy.

arrayDataRows being of type Array[DataRow], dt being of type DataTable, and text being of type string
1. arrayDataRows = dt.Select("[ID] = "+text)
2. arrayDataRows = (From row In dt.AsEnumerable() Where row(“ID”).ToString.Trim Equals text).ToArray()
3. arrayDataRows = dt.AsEnumerable.Where(Function(row) row(“ID”).ToString.Trim=text).ToArray()

I’m not 100% sure on the syntax cause I wrote this out quickly on the fly, but hope this helps. I personally like the #2 or #3. #3 let’s you do more with it I think. There might be a few other ways to do this also.

After you create your array of rows, you can access each row that matches with a ForEach or just access the first row with index of zero. For example, arrayDataRows(0).Item(“Marca”).ToString = “M09786”.

EDIT: I suggest you manipulate the datatable then write range it, but if you do want to convert the row to a row number, then you will need to make some adjustments to the functions. I’m not sure I have a working example of that at this time, though.


1 Like

Thaks your solutions are good however, I haven’t found how I can get the row number to write the result of this row.


Datarow[ ] results = yourdatatable.Select("[ID]='Q0192928338'");

then for Row index - yourdatatable.Rows.IndexOf(results(0)) //assuming you have unique records so only one result you will get


1 Like

Could you attach the sample XAML?

Did someone sent you the XAML sample for this? Because I could really use it right now.