Find a cell position in Data Table


#23

Thanks for quick response, but I am receiving below error
" Assign : Exception has been thrown by the target of an invocation"


#24


#25

Hi Arivu96

I got the answer and I used below format.
dt.rows(rowindex).item(column index)=“my value”


#26

Is this work on for each row???
i’m also working on this type of task and i want to get the index of the row for consecutive cells…
Thanks in advance.


#27

Hi @Prakash_Raj
Yeah, so you can get the index using the row object.

For each row In dt1
    rIndex = dt1.Rows.IndexOf(row)

This same thing can be done with other arrays as well.

An example use-case for this might be if you would like to continue with the last processed row item, so you would store the index then skip all the row items to that index.
—It would look like this:

For each row In dt1.AsEnumerable.Skip(rIndex) //with DataRow as Type Argument
    rIndex = dt1.Rows.IndexOf(row)

In that use-case, if an error was to occur and exit out of the loop, when a retry attempt happens, it will skip to the last index that was being processed at the time of the error.

I hope this info is helpful.

Regards.


#28

I am used this method it will get the first cell index. how can i get the row index of consecutive cells any samples available.


#29

Hi.

I don’t understand what you want to do. Can you provide some screenshots or a better explanation?

Just to rehash what I posted previously…
You can get the index of consecutive rows by using a For each.
For example,

For each row in dt1
    Assign index = dt1.Rows.IndexOf(row)

And, that will return set the index for each row in the table.

EDIT: also, that example is pseudocode so you can replace each line with its corresponding activity.

Regards.


#30


This is the excel sheet. In this sheet i’m extract as a data table and process through for each row in get row item to iterate row by row and finally i want to write a message(column) in excel one by one when get row iteration. How can i do this process.


#31

Ok so there are 2 approaches that I will touch on. 1) assign the message to the data table, then use Write Range to update file, or 2) use Write Cell with the row index of the iteration

For first approach, it would look something like this:

Read Range to dt1
For each row in dt1
    <process iteration>
    Assign activity: row("Message") = "message"

Write Range // using dt1

Using the Assign activity like this let’s you update the data table using the Column name or index as you loop through each row. You can then use Write Range back to the file either inside the loop or after the loop.

Second approach would look like this:

Read Range to dt1
For each row in dt1
    Assign activity: rIndex = dt1.Rows.IndexOf(row)
    Assign activity: colAlpha = Convert.ToChar(dt1.Columns.IndexOf("Message")+65)
    <process iteration>
    Write Cell // using range: colAlpha+rIndex.ToString

So in this approach, you would need the row number and probably the column to be used for the range in the Write Cell.

Apologies if I make any mistakes, but hope this helps answer your question.

Regards.


#32

it works thanks for you reply…


#33

Could you pls share the xaml file for the above im trying to find empty cells for each row and fetch the column name or index