I have multiple columns in Excel and want to convert a certain column to a LIST; how can I do this? Can someone clarify in steps?
Hi @Hemant2
Please check the below thread:
add last instead of .ToArray use the .ToList and it will converted to list
Regards
Hi @Hemant2 ,
- Use the “Read Range” activity to read the Excel file and store the data in a variable named
Input_DT. - Create a variable called
Column_Listwith the data typeSystem.Collections.Generic.List<String>. This variable will hold the data from the specified column. - Use an “Assign” activity to set the value of
Column_Listusing the following LINQ query:
(From row In Input_DT.AsEnumerable() Select Convert.Tostring(row("column_Name")) ).ToList()
Explanation of the LINQ Query
The LINQ query (From row In Input_DT.AsEnumerable() Select Convert.ToString(row("column_Name"))).ToList() performs the following steps:
From row In Input_DT.AsEnumerable(): Iterates over each row in the DataTableInput_DT.Select Convert.ToString(row("column_Name")): For each row, it selects the value of the specified column (column_Name) and converts it to a string..ToList(): Converts the selected values into a list of strings.
Regards,
Vinit Mhatre
Thanks @vrdabberu and @Vinit_Mhatre ![]()
You can simply use the below steps… @Hemant2
Check the below steps:
→ Use the Read range workbook activity to read the excel and store in a datatable.
→ Use assign activity to write the LinQ Expression,
dt.asenumerable().select(Function(X) X("Column name").toString).tolist()
Regards
Hi @Hemant2
Read the Excel (Output=dt)
Use For each Row
Inside the loop create a list variable called columnList (Initialize the list also)
Use assign activity
columnList= dt.AsEnumerable() Select row(“YourColumnName”).ToString()).ToList()
Hope this helps you
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.