I am new to UiPath and currently working on a problem, to combine all Sheets (having same headers) into one Sheet.
For this I have read all Sheets using Get Workbook Sheets, and then have looped them to read the datatable from each sheet, using ForeEach. Check Screenshots below.
Now I want to combine all these datatables into one datatable, how can I do it.
If the column headers are somewhat similar or each table has some matching columns then you can use merge datatable activity to merge the tables.If the tables has even one matching column then you can set MissingSchemaAction Property to Add in the properties pane.
I am trying exactly the same you mentioned but still I am facing the same issue which Ankit was facing. Merge datatable activity is actually overriding the destination data table after every iteration instead of merging the source data table .
Thanks!!!
Perhaps you have already resolved this. I found your question because I faced a similar problem. I believe that the solution lies in variable scope.
My merged data table was declared in the body of my loop. Since you have to allocate a data table using new this means that the merged data table is being wiped each iteration of the loop. It isn’t that the merge table command is overriding the table, rather the merged table begins anew each cycle. To fix this problem, I declared the data table above and outside of the loop (Just change the scope to the parent activity of the loop).
I hope this helps anyone else who runs into this problem. If you are tinkering and start declaring variables within an activity you may accidentally limit or expand their scope.