Hello Every One i have the following problem:
I have a String: tmp_MyString = “2298,1936,2316,2092,1948,2247,2255,2736,2735,2908,2904,2885”
Now i have to add this string to another datatable under a specific Column “Kamapgnennummer” in each row like following
How can i do this ??
Thanks in advance
postwick
(Paul Ostwick)
October 28, 2021, 5:17pm
2
Convert the string to a list. For Each loop through the list and Add Row each value to a datatable. Then use Write Range to write the datatable to the H2 range.
@postwick Thanks for quick Response, But the H2 Range is not fixed , it will keep changing
I mean the Column “Kampagnennummer” might be shifted to some other range like I J K L etc as well
postwick
(Paul Ostwick)
October 28, 2021, 5:31pm
5
That’s why it’s a range. You can just designate the starting cell and it will write as many rows as it needs.
postwick
(Paul Ostwick)
October 28, 2021, 5:31pm
6
Then you need to account for that and provide the correct range to the Write Range activity.
Hi
Hope the below steps would help you resolve this
Initially use a excel application scope and pass the file path as input and inside that scope use the below activities
Use a assign activity like this
arrvalue = Split(tmp_MyString,”,”)
Where arrvalue is a variable of type Array of string
Now use a excel application scope and pass the file path as input and read the data with read datatable activity and get the output as dt
Now use a assign activity like this
Str_position = Convert.ToChar(dt.Columns.IndexOf(“Kamapgnennummer”)+65).ToString
Where str_position is a string variable
Again a assign activity like this
Counter = 0
Where counter is a int32 variable
Now use a WHILE LOOP like this with a condition
Counter < arrvalue.Count
Inside the loop use a WRITE CELL ACTIVITY
Where mention the cell range like this
Str_position + (counter+2).ToString
And in input value mention as arrvalue(counter)
Next to this write cell activity inside the while loop use a assign activity like this to increment the counter value
counter = counter + 2
That’s it
Cheers @Tarif_Mohammad
1 Like
Joe_Osubu
(Joe Osubu)
October 17, 2022, 9:23am
8
Ok there is a new method I discovered and it is so easy to use. The activity is called “update datatable”. Use a write range to read your datatable and then add a for each activity. In the body of the for each place the update datatable activity and reference the default currentrow variable of the for each activity as the datarow object and the column you want to populate. You can use a write range or output datatable to display it as a string