Iterate through Excel Row

Hi there,

I got a list which I need to iterate through. I want to perform certain actions with each of the numbers one by one. I’d like to assign them to a variable, perform the action and then continue with the next one. Any ideas?
Contacts.xlsx (7.3 KB)

1 Like

load the file into a datatable then a for each data row

@SSchmitz

  1. In the Sequence - Add an Excel Application Scope and specify the file path to the Excel File.
  2. Within the Excel Application Scope - Do - Add a Read Range activity.
  3. Specify the SheetName from where to pick up values. (keep the Add Headers property selected if there are headers)
  4. In the Properties pane - Output - Press Ctrl+K and create a variable of type DataTable.
  5. Add a For each row activity (ForEach row in DataTable created above)
  6. Perform the required actions .

image

So if I want to use one value after another in my list as a variable what do I enter in assign?

@SSchmitz
Idealy the current Vertragsnummer ist already accessable under number(0)

@SSchmitz

You can use number(0).ToString .

As a test : Please add a Write Line activity inside the ForEach loop and type in number(0).ToString

This will essentially loop through each row and write the text available in the first column (Index of which is 0)

What am I doing wrong?

1 Like

Hi
Hope this sequence would help you resolve this
—Use a excel application scope and pass the above excel file path as input
—inside the scope use a READ RANGE a activity and get the output with variable of type datatable named dt
—now use a FOR EACH ROW activity and pass the variable dt as input
—inside the loop we can simply use a assign activity to make changes or any manipulation we want
Like
row(“yourcolumnname”) = “the value you want”

Cheers @SSchmitz

1 Like

Hi @SSchmitz,

I have done the Excel iteration. Change the excel file path and test it.

ExcelIteration.xaml (7.8 KB)

Thanks!

3 Likes

This works great! Thank you Sir!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.