Extract Column names of excel and use them as variable

Hi, I have a use case to extract the column name from the excel sheet and use them as a variable in Uipath.


Like i have to get column names(CabinetName, Operation, Name…etc). These names will be used as the key of a json and hence is dynamic. Please help…

Hi,

You can use Read range and read the complete excel file and use for each and in for each use datatable.columns and arument as system.data.datacolumns and inside foreach use assign and use item.columnname.tostring and append.

Refer the below workflow and the sample excel sheet, so the below workflow will give you all the column names in a single variable separated by space.

Sequence4.xaml (8.6 KB)

Reading.xlsx (8.0 KB)

1 Like

@raviranjan,

extract column based on index like following statement,
String strCabinet = dt.columns(0).toString();

Regards,
Pankaj

Thanks a lot. It helped. Just one question though. We are appending the every column name with previous one. So again we need some method to separate those names using suitable delimiter(say comma","). How do i do that.

Hi @raviranjan

Yes you can separate them using space

Split(Str," ")

Refer the below workflow

Sequence4.xaml (10.5 KB)

2 Likes

Thank you very much guys. Will keep you posted if need further help.