I have 4 array strings , want to add them in Single Datatable. Any leads helps
Arr1={1,2,3,4}
Arr2={abc,def,fgh,jks)
Similarly Arr3, and arr4
Thanks
I have 4 array strings , want to add them in Single Datatable. Any leads helps
Arr1={1,2,3,4}
Arr2={abc,def,fgh,jks)
Similarly Arr3, and arr4
Thanks
Welcome to Community!!
Regards,
Create a datatable by using build datatable activity.
Create a array of String variable and store {Arr1;Arr2;Arr3;Arr4}.
Use for each to iterate the above variable.
Inside for each use another for each to iterate the Arr1
Use add data row to add the data to the rows to the datatable.
At last use the write range workbook activity to write the datatable to excel.
Find the below workflow that I built with your condition.
Expressions_Practice.xaml (14.3 KB)
Output excel -
Hope it helps!!
Do you want the combined output to be Arr1 in one column, Arr2 in another column, in the same row?
Do you want 8 columns with values 1, 2, 3, 4, abc, def, fgh, jks?
Do you want 4 columns with two rows, one row for each array?
Something else? You have to show us what your desired output looks like or we can’t help.
{currentItem,arr2(indexvar,arr3(indexvar),arr4(indexvar)}
Assumption is all arrays have similar number of items
Cheers
newRow = dtCombined.NewRow()
newRow("Column1") = item.ToString() ' Assuming you want to add the value to the first column
dtCombined.Rows.Add(newRow)
Hi @Kniranjan555
Use Build data Table activity and create the volumns and store it an variable say dt_combineddata.
2. Intialize all your 4 arrays.
E. Use For each loop to iterate through each say and add the items using Add Data Row activity and store in dt_combineddata variable.
4. Use Write Range Workbook avtivity at last to store all the combined data in excel.
Hope it helps!!
Build DataTable - configure the 4 columns - dtResult
Assign Activity:
dtResult =
(From i in Enumerable.Range(0,arr1.Length)
Let ra = new Object(){arr1(i),arr2(i),arr3(i),arr4(i)}
Select r = dtResult.Rows.Add(ra)).CopyToDataTable
When arr1,2,3,4 are of different length we can modify and handle as well by filling up with null values
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.