How to change multiple file formates

Hi Guys,
I want open the particular folder from that folder select the .XLS type files and open that file then save the file format from .xls to .xlsx with current date and time. From that particular folder daily records has been added. how to i do this in a flow
Can some one help me on this.
Thanks

1 Like

HI
hope these steps would help you resolve this
–use a assign activity like this
arr_filepath = Directory.GetFiles(“yourfolderpath”,“.xls”)
where arr_filepath is a variable of type array of string
but still it will contain xlsx file as well along with xls

–now use a FOR EACH activity and pass the above variable as input and change thet ype argument as string
–inside the loop use a IF condition like this
Split(item.ToString,“.”)(1).tostring.Equals(“xls”)
if true it will go to THEN part where we can use EXCEL APPLICATION SCOPE and mention the file path as item.tostring and inside the scope use READ RANGE activity and get the output with variable of type datatable named dt
–now use a WRITE RANGE ACTIVITY from workbook activities and mention the file path as
“yourfolderpath”+“\”+Now.ToString(“dd_MM_yyyy”)+“.xlsx”

and mention the datatable as dt and enable the add headers property

Cheers @vivek_sivam

  1. Get the list of excel files from a folder
    lstFiles = Directory.GetFiles(folderpath,“*.xls”)
ForEach file in lstFiles
{
   Open Excel File using Start Process or Open Application
   Send Hot key F12, it opens Save As Dialog box
   Select file format and enter path & filename , click ok
   //optional: check if you get any warning while saving the file and click ok
}

Regards,
Karthik Byggari

Hi @Palaniyappan
From this flow we are able to open the all the .XLS files then click on convert or save as option so that only my file conversion has been done. Because my file(xls) have some format issue
Thanks

Fine
May i know the issue if any, you were facing
@vivek_sivam

From file it will show as .XLS but inside the file it have the html
That’s the problem
@Palaniyappan
Thanks

It is possible to create some examples
Thanks

Hi
Then we can open the file using Start process and then copy with Send hot key with key as ctrl+a and ctrl+c
Then open another excel with start process and paste with ctrl+v

Cheers @vivek_sivam

@Palaniyappan
Can you please let me know how to open the excel files from the particular folder(recently added)
Assist me on above one
Thanks

You mean like you want the last added excel file from a folder and open it
@vivek_sivam

@Palaniyappan
Yes Exactly. For example in a folder today added files are like
report1.xls
report2.xls
report3.xls
I want’s to open all the files and do the followings click activity
Thanks

@vivek_sivam,

The below query will get you the files created today in that directory,

Directory.GetFiles("path_to_directory").Where(Function(x) New FileInfo(x).CreationTime.Date = DateTime.Today.Date)

Thanks @sarathi125
But i want to open the excel file and change the file type using click activity or we can use any activity. Can you please give some examples like this

@vivek_sivam,

The code below will get you the files in a Collection of FileInfo type.

Directory.GetFiles("path_to_directory").Where(Function(x) New FileInfo(x).CreationTime.Date = DateTime.Today.Date)

You need to use a For each activity then inside that open file by file, then try with the below xaml to save the excel as your required format.
Excel_SaveAs.xaml (46.5 KB)

@sarathi125 i have download your flow and try to execute i didn’t get any error. I can’t get output
Thanks

Hi @vivek_sivam,

Have tried this one ?

https://go.uipath.com/component/file-converter

Regards
Balamurugan.S

Hi @balupad14
In my case i can’t able to use this method. Because my file have .xls format but inside the file it contains html content so it won’t work.
So only i have tried to open the excel and click on save as option
Thanks

1 Like