In excel application scope can i read 2 sheets and add them to array and do for each?


I am having two sheets in which i need to perform same actions so , i am trying to add for each for 2 data tables,is this possible? .

Hi @MitheshBolla ,

Could you maybe explain a bit more as to what you want to perform and What is the Output you Expect ?

Also, Yes, we should be able to loop through the Datatables that are in a List, but we would need an Outer For Each loop which loops through the List of Datatables.

1 Like

@MitheshBolla For each row in datatable will accept only datatable variable.

If you want to pass the datatable values you can use a foreach activity and put for each row in datatable inside of that foreach. The you can loop through the array and pass the datatable to the Foreachrow in datatable activity.

1 Like

how to take array for 2 DT? in c#

I had One excel,
I had 5 sheets
i had read each sheet as d1 , d2,d3,d4,d5.

I want to loop d1 and d2

for this i need to take list of arry = listofDt?

(i want to loop 2 data tables in for each, facing issue at creating list of datatables)
so that in for each i keep listofDT

EachDt=item.tosting()

Hi,
Attaching one workflow.Just check if that helps you.

Sample.zip (10.0 KB)

1 Like

image

Assign
ListOfDatatable= {approval,RFE}

Are you using the same ?

1 Like

Yes , but i am using c# platform, so vb systax is not working

Are the columns the same in each sheet? If so, read both sheets then Merge Datatable into one, then For Each Row in Datatable through the combined datatable.

1 Like

columns are Different, almots 85% operations are same in both sheets, thats y i need to foreach each data table.

Read Range inside the loop, then.

Get Sheets
For Each item in sheetsArray

  • Read Range
  • Do operations on DT
    //end For Each
1 Like

how to array 2 dt in c# , can u provdie me syntax

You don’t use C# you use activities. Excel Application Scope, Get Sheets, For Each, Read Range, etc.

1 Like

i had 5 sheets, but only want 2 in for each and there is no Get Sheets activity.

Then you’re on an old version of UiPath.Excel.Activities.

Upgrade that dependency.

If you only want two, remove the ones you don’t want from the array that Get Sheets produces.