How to display read range datatable using msg one by on using for each loop

Hi All,
Can someone help in issue,

I have excel with coulmns A1:B10 so i want it to store in datatable and then wants to display cell wise using for loop

1 Like
  1. Use Excel application scope
  2. Inside that, read range activity and create a variable in the output pane by pressing ctrl + k
  3. Use for each row activity and inside that, use message box

Hi @Dhananjay_lavate

Assign each cell value to one variable and use it inside for each datatable then pass the variable into the message box.

but i want to display data cell wise one by one from datatable how can we do?

@dineshsigaram can you please help me to assign

Here it is @Dhananjay_lavate,
It will display the value of column A and column B in that particular row


Hi @HareeshMR
i tried same but its showing only first row continesly

1 Like

Hi @Dhananjay_lavate

Hope these steps would help you resolve this
–use a excel application scope and pass the file path as input
–use read range activity and get the output with a variable of type datatable named outdt
–use a for each row loop and pass the above variable as input outdt
–inside the loop use a message box or write line activity and mention like this

this would display all the values in all the column of the particular row in iteration, that is all the cells

hope this would help you
Cheers @Dhananjay_lavate

Can you attach the workflow or the screenshot if your workflow?

Please find attched screnshots of flow

i want to store each row value in variable…please help…i tird this row(“clmn1”).Tostring…but its showing only fist row and first clmn

1 Like

Hi @Dhananjay_lavate
Pelase find the attached workflow it will help you to understand How we can read values from excel Row by (7.8 KB)

aaha row you want as a datarow right…
if so
–use a excel application scope and pass the file path as input
–use read range activity and get the output with a variable of type datatable named outdt
–use a for each loop and pass the above variable as outdt.Rows and change the type argument property as datarow in the property panel of for each loop
–inside the loop use a assign activity like this
–out_row_array = item.ItemArray()
where out_row_array is a variable of type string array
which will have the value of all the columns in a row, so that we can fetch the needed column value in a row by mentioning the array index
like if we want to know the value of 4th column in that row
then out_row_array(3).ToString in a write line activity will display that value

Hope this would help you
Cheers @Dhananjay_lavate

Are you converting the data table to string in the output data table activity? You are reading only two columns of data excluding the headers in read range activity,so when you try to convert it , it will have only two values in that.

then we need to one thing
–create a dictionary variable in the variable panel named in_dic of type (of string,string)
and mention the default value as new dictionary (of string, string)
–then use a for each row loop and pass the datatable as input and inside the loop mention like this in the assign activity
in_dic(row(“Order Details”).ToString) = row(“data”).ToString
this will add all the value to dictionary with key value pair
–put the open browser and other activities outside or next to the for each row loop
–inside the broswer or wherever if we want to the use the value obtained from the datatable we need to mention like this
in_dic(“Username”).ToString //output will be rgupta
here Username is the key and its value is rgupta in the dictionary
this will work for sure…
Cheers @Dhananjay_lavate