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
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
will you later write out the data to excel?
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.
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:
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
implement the workflow as provided above.
Index is the counter variable having initial value=0
If your problem is solved , marked it as solution for future reference.
I have to add data into 2-3 columns but by using your solution all different data is being added into same column
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
yes you got it right
we have to do the same way