Convert xls to xlsx

Hello everybody

Please I need to convert 10 excel file from *xls to *. Xlsx
Any help please.
Best regards,

You can use Move file Activity and simply change the file type.
From Path: “TestNumber.xls”
To Destination : “TestNumber.xlsx”

2 Likes

Hi @ifranity

The Read Range activity is made to read any excel extension(including .xls)

The Write Range activity can be used to write to xlsx if we specify it in the path.

we are going to these two facts and do this :

see the attached file below for the whole workflow

XlsToXlsx.zip (29.7 KB)

Ps 1: don’t just change the extension of the files when converting that may damage the files.

Ps 2: you need to add a loop through the files in your folder and then apply the two activity above on them, so you will have to add an assign to getFiles and then loop through the resulting array.

Regards,
Reda

2 Likes

@reda Converting XLS to XLSX is fine by just amending the filet type due to the restrictions on XLS and will not damage the file, I have used it and have had no issues with well over 10,000 files.

@ifranity Also you would need a more complex workflow as read range only handles one worksheet -
You would need to get all the worksheet names (they could be different in each workbook), you would then need to loop through each worksheet and using the Read and write each sheet accordingly - this also changes any formatting stored.

2 Likes

@TimK I’ve just tried it now and here is what I got :

I think what you mean is transforming Xlsx to Xls, this will work but even then you will have this message when you want to open it:

thanks buddy, can you provide an example with two file excels for example
Because me I can do the loop for reading range and after getting file in an array but what I don’t understand is the write range in your scope?

big thanks,

best regrds

Hi @ifranity

Well sorry for being late but here is the workflow, it will convert files as long as they are in the same file of the project(xaml file), if you want to change the path just change it inside the first assign activity.

otherwise it should work just fine.

enjoy :wink:

MultipleFileConvert.zip (37.4 KB)

Regards,
Reda

2 Likes

Are the files all in one directory? If so, you should use directory.getfiles filtered by type *.xls then use a for each activity to go through each file, read range, write range saving as .xlsx, then delete the old .xls file.

1 Like

@Dave yes all files are on the same directory, like this you wanna say :
Directory.getfiles(“Input\ * .xls”) that showing me error.

@reda Ican’t see the activities in your worflow

a screenshoot will be great from you

thanks Man :wink:

Ok here is the zip file reuploaded and the screenshot :

MultipleFileConvert.zip (37.4 KB)

image

2 Likes

thanks but that dont work I have to sheet by excel and when I duplicate the read range and write range that show me error even with one sheet.

thanks at all.

Hi @ifranity

I wanted to give a working framework on how to approach the conversion, if you have multiple sheets then you should read their names and do the same for them and probably you will end up with two for each activities one for the file and the second for each sheet.

Regards,
Reda

This workflow requires you to have excel installed as it uses excel activities instead of workbook activities. This is needed so you can use the Excel.GetSheets method/activity to get all the worksheets in the workbook.

ifranity.zip (2.9 KB)

There is a easiest way for this, i.e, using command prompt.

I have shared the details in the below thread.

2 Likes

Hi Nivaskannan

Have you ever got this working with Invoke Power Shell? I can get it to work from cmd and I got it working in VBA. But I cannot get it working in UIPath.

Hi Reda,
I may be too late to reply but this may help some other with similar query, replacing the file name from excel.xlsx to excel.xls may looks like file got converted but actually it’s not since both have different type of OLEDB connection string. So, ideally in C# we’ll use microsoft.interop or openxml to read the file with xlsx connection string and write with xls connection string. We can use excel application scope for reading and writing that back to xls file before reading in workbook sheet.