How to get index and value in for each row data table

How to get index and value in for each row data table

Example for sample excel:

column1
32
45
65
45

Need Index number and value
output:
0 – 32
1–45
2–65
3–45

both are output are in integer type

thanks
shaik

@shaik.muktharvalli1

Use For Each Row in Datatable activity

Assign IntIndex variable to index property.

Inside body you will have index and value in integer

Thanks,
Ashok :slight_smile:

@shaik.muktharvalli1
DataTableIteration.xaml (9.9 KB)
check the file

in for each row activity go to properties panel and set the variable in the Index. inside the loop u can use that index to get the value.

@shaik.muktharvalli1

You can achieve this by using the “Excel Application Scope” activity to read the Excel file and the “For Each Row” activity to iterate through each row of the data table. Here’s how you can do it:

  1. Drag and drop an “Excel Application Scope” activity onto your workflow.
  2. Configure the “Excel Application Scope” activity to specify the path of your Excel file.
  3. Add a “Read Range” activity inside the “Excel Application Scope” to read the data from the Excel file into a DataTable variable.
  4. Drag and drop a “For Each Row” activity below the “Read Range” activity.
  5. In the “For Each Row” activity, assign the DataTable variable from the “Read Range” activity to the “DataTable” property.
  6. Inside the body of the “For Each Row” activity, add an “Assign” activity.
  7. In the “Assign” activity, use the following expression to get the index and value for each row:

index = row.Index.ToString

value = Convert.ToInt32(row(“column1”).ToString)

Make sure to replace “column1” with the actual column name from your Excel file.

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