Search code examples
rpauipath

loop through datatable using column name but not exact column name


I am trying to get cell values of particular column having Column name which is not fixed after particular words. i need to loop through Datatable and get values from column having column name as something like 'Value @02/29/2019'. Here Date is changing but i want to know whether we can have something like contains or 'Values%'.

I tried regex but no luck.

expected is like: - for each row (Test_DT) - assign row("Value%") to CellValue - end for


Solution

  • We can have something like contains to check the columns, try the following:

    1. Create an excel application scope
    2. use readrange to get data from excel inside a datatable.
    3. use for each activity to loop through dt.rows
    4. use for each acticity inside your first one to loop through dt.Columns
    5. inside your foreach column use an if activity to check if col contains "Value @"

      col.ToString.contains("Value @")

    enter image description here

    Also you will have to change typearguments of your foreach activities otherwise you will get "Option String On Disallows Late Binding" error

    enter image description here