Assigning values in datatable to variables dynamically

I have a datatable with header and i want the headername asign to a variable dynamically.
So i can asign the variable with a value from the datatable.

For Example: Header from datatable is |Name|Street|City|ID|

Variable: Name = CurrentRow(“Name”).ToString

@Chris2046,

You can get the the Datatable columns using dtVariable.Columns(0) this code will give you first column name. dtVariable.Columns(1) will give you second column name and likewise.

@Chris2046

There are several ways to get the column names
if you want to get all column names you can use
dtinput.clone() this will give list of values containing all column names.

or

if you know the index of column name you can go with as per @ashokkarale suggestion.
dtinput.column(0)

if the positions are dynamically changing
based on some key(header) if you know initially you can get the index from dtinput.clone with this you can build your logic

And make sure while reading the your excel Add Headers proprty should be checked.

if not you will column names ad Column1, Clomn2…

if you want to go with this you can use Column1 as column name

Name = currentrow(“Column1”).tostring output will be Name

Happy Automation!!