I want to consolidate multiple excel - sheet data into one excel.
example -
abc.xls - sheet 3 - need to read.
def.xls - sheet 1 - need to read.
xyz.xls - sheet2 - need to read.
output.xls should have all consolidated data available.
Let’s say like we have aground five sheets or workbooks and all has to be merged
—now we shall create two datatable variables named dt and finaldt with default value as New System.Data.Datatable defines in the variable panel
—now use a ASSIGN activity like this arr_files = Directory.GetFiles(“Yourfolderpath”,”*.xlsx”)
Where arr_files is a variable of type array of string
— for low take one excel file path like arr_files(0).ToString and pass that as input to excel application scope and use read range and get the output with a variable of type datatable named Finaldt
—then use a CLEAR DATATABLE activity and mention as Finaldt and this is done to get the table structure
—now use a FOR EACH act and pass the above variable arr_files as input and change the type argument as string
—inside the loop use a EXCEL APPLICATION SCOPE AND pass the file path as item.ToString
—inside that scope use a READ RANGE activity and get the output with a variable of type datatable named dt
—then use a MERGE DATATABLE ACTIVITY and mention the source as dt and destination As Finaldt
—followed by this use a CLEAR DATATABLE activity and mention as dt
So that for each iteration of excel files data will be first fetched with dt and then merged to Finaldt
As dt is now cleared for each iteration new data from excel will be obtained and as Finaldt is not deleted it will keep all the data merged together
Atlast we can use write range activity and mention the input as Finaldt