i have ms excel workbook with multiple sheets in it with data. i wanted to combine all the data in to single excel sheet into same work book. can anyone help me with it.
- Read Range(Excel not workbook) → give the the sheet Name as "EachSheet " and stored it to datatable called dt.
- Add If Loop if file.exists(“Output.xlsx”) Then → Append Range → “Output.xlsx” → SheetName = Eachsheet → dt. Else → Write Range → “Output.xlsx” → SheetName = Eachsheet → dt.
Hope it Helpful!!
Excel Application Scope (workbookPath)
Assign combinedDataTable = New DataTable
For Each sheetName In sheetNames
Read Range (sheetName)
combinedDataTable.Merge(currentSheetData)
End For
Write Range (combinedDataTable) to newSheetName
Save Workbook
=> Take Use excel file activity and pass the Excel File path.
=> Inside use excel file activity insert the for each excel sheet activity. Output - CurrentSheet
=> Inside for each Insert the Read range activity to read the excel file. In the range field give the CurrentSheet. Output - dt_Excel (Datatable Variable)
=> After Read range activity insert the Append range workbook activity to append the datatable to excel in one sheet. In sheet name field give the sheet name and give the dt_Excel in datatable field
Check the below image for better understanding.
Note - You have to use the Modern design activities to use the above excel activities.
Hope it helps!!