How to preserve Format while copying from an excel file

I am simply reading from an Excel file and writing to a new excel file and it works.

I have questions though.

dummy1 dummy2

If you see, my source file(dummy1.xlsx - on the left hand side) and my target file(dummy2.xlsx) has different format, although content is exactly same. So why UiPath can’t copy with extact format also? When reading from the file I am using PreserveFormat…I thought it would preserve the format.

Secondly the sizes of the two files are also different.

Dummy1 is 18kb while Dummy2 is 14 kb - probably for the difference in format?

1 Like

preserve format is meant to get same format of the COLUMNS in the source file, i.e.,if the column is of type general or number the same format would be retained …but that doesn’t mean that it would take filter with it…and when we use read range activity we have a property called add filters, that would take applied filter to the data…take only the filtered data…but it is unchecked by default that means it will take all records even though you have applied filter to it… @sujoy_mukherjee
So if you are trying to write a excel with filter applied, we have to open the file with start process, and then use click activity to apply filter on it…
or for your case you can use MOVE FILE activity or COPY FILE activity
Or to make even better you can use the custom activity been developed by one of our …with this

Hope this would help you buddy
Cheers @sujoy_mukherjee



Although if you need to preserve the format of the excel along with the colors and formatting it would be better to use the send hotkeys in excel to Copy (Ctrl + C) and Paste (Ctrl + V).

  1. Open excel 1
  2. Select all the data with hotkeys
  3. use send hotkey activity with (Ctrl +C)
  4. open excel 2
  5. use send hotkey activity with (Ctrl +V)

Best regards
Mazin Zunnoon

Any issue still buddy… @sujoy_mukherjee

1 Like

Thanks @Palaniyappan

Thanks @mazin_zunnoon

1 Like

Thanks @Palaniyappan
I will try both yours and Mazin’s suggestions and will let you know.


Did that work buddy @sujoy_mukherjee

hi @Palaniyappan…that works using your suggestions.
Thanks a lot buddy :smiley:


Thats Fantastic buddy
Kindly make a solution that could help others as well buddy
Cheers @sujoy_mukherjee

Sure @Palaniyappan

One question…I am doing Level 1 Lesson 9 and now learning how to apply Filter in excel.

However in my case one column has date value and I need to apply filter on a date range( for example 1st April 2019 to 30th April 2019).

I am using Filter Wizard as they shown in the video but how to mention the range here?

1 Like

Buddy you can use filter datatable activity @sujoy_mukherjee
like this

Did that work buddy @sujoy_mukherjee

@Palaniyappan no buddy.

What I did, after I read and filter from the excel file using Filter Datatable activity (as you have shown) I use Output Datatable activity to store it as a string and then write it to a new text file using Write Text file.
It is throwing an Exception - System.FormatException.
On clicking details, it is showing String is not recognized as a valid DateTine.
Do I need to convert it to Date before writing to the text file?

1 Like

Yes buddy
may i know the format of the date in string that you get
To check that in an exact way use writeline activity to print the value that you get from excel so that we will come to exact format we want…
kindly provide that format buddy
we can easily sort this out from there @sujoy_mukherjee

@Palaniyappan sorry for asking this but how to find out the format?
I am sorry a very basic question may be.

Can i have a view on yur xaml buddy if possible
Cheers @sujoy_mukherjee

Here it is @Palaniyappan

Main.xaml (13.6 KB)

@Palaniyappan buddy have you seen my xaml file?

working on it buddy
two mins pls
Cheers @sujoy_mukherjee