Can we convert excel column names to variable?

Hi,

There are some column name written in excel like below :

DoB
DDMMYYYY

I am copying the same. To enter the values from excel to desktop application, using row(“DoB
DDMMYYYY”).ToString the space and everything are same just copying from excel. Still it is giving error like this column is not found. Is there any way to fetch the column name by only index. Please suggest a way

Hi @garima.sriv12

Use like - row(0).ToString
to access column by index instead of name. Replace 0 with the desired column index. This avoids issues with hidden characters in column names from Excel.

If helpful, mark as solution tick.
Happy automation with UiPath

@garima.sriv12

you can get all columns as list from there you can columns based on index. to get the columns as list, you can dt_input.clone() it will give all column names

Take assign
create a list variable and pass it in To section and in value field give dt_input.clone()

from there you can gett all column names in list variable.

@garima.sriv12

Yes you can use the column number as well A - 0 ,B-1 etc as you need

cheers

Hi, thanks but will it work if there are many rows in excel? If yes, then how can I loop through. Please mention the syntax also.

@garima.sriv12

Just loop with For Each Row in dt and access columns by index like row(0).ToString.

Happy Automation

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.