How to add data to row one by one in a single column

Hi all . Inside excel application scope , i am using for each row activity which will scrap some value and will add to the row in a column . Similarly, for 2nd iteration it will add to the 2nd row … etc. I am able to assign value to only first row only . How to add to other rows can anyone help me ? Thanks in advance

Hi @simadri

What is the issue that you are facing while adding the second row.

@simadri create a counter variable of int type with default value 1 now in for each row. Use assign activity and give like this counter=counter+1
Below it say you writing data to B column in the place of B give like this “B”+counter.tostring
So that it will write data in every row.

This looks contrast
Kindly elaborate a bit more in this pls
That could help us to go in a right direction
Cheers @simadri

Hi @Palaniyappan @venkatmalla6 I have one existing column “CSAP Score” below which I am writing data dynamically (using OCR activity).I dont know how it can write data to each row one by one .I know why it is writing only to first row coz I am assigning it as datatable2.Rows(0).Item(“CSAP Score”).What I want is for each row it should be like row(*) something like this so that it will assign one by one for each row with different value . attaching screenshots.err2
Thanks for ur reply :slight_smile:

@simadri so you’re getting data from a website or from any other source.

yes from a site

@simadri seems like you haven’t used for each row activity.
-use for each row activity and pass input variable of datatable.
-then inside body you can use open browser and pass the address and store the ouput which you want in a variable.
-there you can use assign activity like row(CSAP SCORE).tostring= the variable name if ocr text
and then use write range activity.

can u be more clear ? sorry I didnt get you . and Isn’t it there anyway to assign value according to the iteration? for example, for first iteration -write it to first row.for 2nd iteration -write it to second row.etc

Hi @simadri
try this…
1.) first take one add data row activity and change properties like this
DataRow = datatable_varible.NewRow
2.) Take one assign activity and assign like this
datatable_varible.Rows(datatable_varible.Rows.Count-1)(“CSAP Score”)=your_value

@simadri New folder (2).zip (7.0 KB) have a look at this zip file replace input dialog with open browser and pass the url and use get ocr text and store it in a variable and give how i give.let me know if any thing goes wrong.

@simadri did you tried the above sample.

yes thank u . but it is writing the same value to all d rows in a column .not different value to each row . @venkatmalla6

tried this. but unable to write data to rows @kalyanDev

Hi @simadri can you please share your work flow here if possible so that it will be easy for us.

As you said for each row you want to add the CSAP Score but as per the attached image you are not using any forech activity.

Hi Kalyan, now I tried using for each row activity where I used the counter variable and set the value as 1 and then increased by counter =counter+1
then used assign activity row(counter)=textimage(i.e the variable i am using to capture ocr value from my site).bt it is throwing " Exception has been thrown by the target of an invocation." exception., Also I cant share the complete workflow as it is confidential and has information abt my company which i cant share. :frowning:

Hi simadri,
i observed your work flow screenshot, As you said for each row you want to add but you are not using any forech activity.

@simadri after get ocr text use write line activity to check whether it is writing data for every row.

hi all I solved it . I was already having each row activity which I have mentioned in the first post . as the workflow is big,cudnt show snapshot of it. Anyway, I solved it by using datatable2.Rows(counter).Item(“CSAP Score”) to my variable and then making counter=counter+1 :slight_smile:

1 Like