Hi @Guru_Koli21
You want to convert the data in the array variables to the datatable, Am I right.
If yes, then you can achieve it by using the Vb code in invoke code activity, follow the below steps,
→ Use the Build datatable activity to build the datatable and add the column in it and create a variable called dt in the Datatable options in properties.
→ Use the Multi assign activity to initialize the items in Array variables,
- Assign -> arrEmpDepartment = {"HR","IT","Account","RPA","DS","QA"}
- Assign -> arrEmpName = {"A","B","C","D","E","F"}
- Assign -> arrEmpID = {"1","2","3","4","5","6"}
→ Then use the Invoke code activity and click on Edit code then give the below vb code in it.
' Populate the DataTable using LINQ
dt = arrEmpName.
Select(Function(name, index) New With {
.EmpName = name,
.EmpDepartment = arrEmpDepartment(index),
.EmpID = arrEmpID(index)
}).
Aggregate(dt, Function(dtable, emp)
Dim row = dtable.NewRow()
row("EmpName") = emp.EmpName
row("EmpDepartment") = emp.EmpDepartment
row("EmpID") = emp.EmpID
dtable.Rows.Add(row)
Return dtable
End Function)
→ Click on Edit arguments and pass the arguments to the code as below,
→ Then use the Write range workbook activity to write the dt to the excel.
Check the below image for better understanding,
Sequence5.xaml (16.2 KB)
Check the below output excel file,
Hope it helps!!