How to add an array data into datatable

I have a bulk of data stored in a variable which is of type array and i need to add that data into datatable.
I have attached the Image for the reference
image
Please specify how to add data into datatable and print it in the form of excel for further solution.

Define a column in that data table that would accept an array type and pass the same to it.

I have tried using add data column to add a column into the datatable and pass on the values to it but nothing works

@Kunal_Jain

Find the workflow:

Sequence.xaml (9.9 KB)

will you later write out the data to excel?

@Kunal_Jain

1 Use read Range activity to read the excel 
2. assign your array.
3. use for each row in  data table activity to iterate the datatble
4. assign array(index) to Currentrow("InputColumnindex").Tostring
5 Use write range activity to rewrite your excel.
1 Like

I assume you are facing difficulty in retrieving the array from the column. If your array is the array of strings then below piece of code might help for you to convert that object to array back.

CType(row(Column), String())

yes
we will be adding the data into excel

When you add a data column, it’s basically adding a column name (or header).

You will need first to add a data column and set an index variable with the default value as 0 so you can perform the solution suggested by Vaibhav:

just have a look to following as it is good to know for scenarios:

when we do have an array we can make string, which i seperated with a from us selected delimeter:
grafik
so, here we made the array flat for the case we want to store all values within an excel cell

when having a string and we want to store each intem in a datatable row/col we just iterate over the array and add the looped value to a in advanced prepared datatable

  • prepare target datatable with e.g. build datatable - dtResult
  • for each activity: item in arrYourValues
    • add datarow activity

in certain case we can handle it with a LINQ and arrive to a more compact flow modelling. But have a first try with a for each

@Kunal_Jain

implement the workflow as provided above.
Index is the counter variable having initial value=0

@Kunal_Jain

If your problem is solved , marked it as solution for future reference.

@Kunal_Jain Try the attached workflow

Example.zip (9.8 KB)

Input

Capture1

Output

Capture

I have to add data into 2-3 columns but by using your solution all different data is being added into same column
image
Check this the below date has to be added into “B” column.

@Kunal_Jain Can you show or provide the sample input and expected output

Test.xlsx (9.4 KB)
Input Sheet
OutputSheet.xlsx (9.2 KB)
OutputSheet

@Kunal_Jain My understanding is we have to read the Number and build data from the input excel and write that in the output excel since I see only two columns in the output excel. Let me know if I am wrong

@Kunal_Jain

Try this workflow:

Sequence.xaml (9.9 KB)

yes you got it right
we have to do the same way