Merging two Excel files into one in StudioX

Hello everyone!

So, I’m having a little in merging two excel files, I will try to explain the automation process. First the Robot downloads both files (they’re sales files) since the beginning of the month, so both files are continuosly growing on lines. I want to merge those two files into a single one so I can paste it on my database, however, all the methods I’ve tried have failed, since they mostly overlap each other instead of one below another.

I’ve read forums, I’ve tried ChatGPT but to no success. I’m currently using Read Range (the Excel activity) on the columns that data is stored, saving it on a System.Data.Datatable variable and Write Datatable to Excel on the first one (this one goes without problem, since the file is empty), but the second one I’ve tried using Write Datatable to Excel but it overlaps with the data already there, I’ve tried using Append Range but it says ‘Error BC30512. option strict on disallows implicit conversions from datatable to readrangeref’

Can someone help me, please?

1 Like

Hi @henrique.quintela

→ Use Read Range Workbook to read both the excels and store the output in Datatables say dt1 and dt2 .
→ Create a new datatable variable and clone it headers

dt_Final = dt1.Clone()

→ Use Merge DataTable activity give source as dt1 and destination as dt_Final. in the same way do it for dt2 also.
→ Use Write Range Workbook to write dt_Final back to excel.

Hope it helps!!

1 Like

Hey! I don’t have either activities… perhaps my StudioX is an older version? Or is this a package? How do I download it?

1 Like

Hi @henrique.quintela

Please Enable Developer in Filter option of Activities Panel.

Regard

1 Like

Hi @henrique.quintela

Check the below image for better understanding:

Make sure to enable Add Headers in the properties Panel of Write Range Workbook.

Hope it helps!!

2 Likes

Just so I’m following everything correctly, how do I store the outputs of read range on datatables?

1 Like

Hi @henrique.quintela

You can see properties Panel on right Hand side there you can click Create Variable and create a variable.

Regards

1 Like

image
Where exactly? Sorry if I’m asking too much

1 Like

Hi @henrique.quintela

You can see the + symbol on right hand side of TabelaDeDados click on that create a New variable and create a variable.

Regards

1 Like

This was helpful. Thank you @Parvathy