Open the downloaded excel file

studio

#1

Hello,

I would like to open automatically the excel file downloaded. The excel file has a different file name every time it is downloaded (It’s a generated report from an intranet web application).

Thank you


Reading excel variable excel files
#2

#3

As you can see, UIPath doesn’t allow me to create a variable with the given expression

Thanks a lot for your help.


#4

change the Fil variable type from string to array string system.string[]


#5

UIPath still outputs the same error…


#6

please upload the workflow.


#7

The workflow won’t work for you because the first thing it does is accessing an intranet web application…


#8

np. I just want to see the workflow and why the error prompting.


#10

Try like this:
string[] yourVar = Directory.GetFiles(downloadsFolder).Where(Function(x) new FileInfo(x).CreationTime.Date = DateTime.Today.Date).ToArray()
Or if you want just the newest one:
string newestFile = Directory.GetFiles(downloadsFolder).Where(Function(x) new FileInfo(x).CreationTime.Date = DateTime.Today.Date).First()

Also note that for these kind of expressions it’s usually better to put them in an Assign activity instead of deafult value for a variable (as it get’s messy to debug/handle errors if f.e. location is unreachable and throws an IO exception).


How to read Excel file dynamically?
How to get the image -Date Taken from UI Path?
#11

Thank you for your answer it really helped me. But if you want the newest file, the request you wrote will not work, it gives the first file found on the list (An alphabetically ordered list).

Here’s an expression that works for this case :
Directory.GetFiles(pathDownload).OrderByDescending(Function(f) New FileInfo(f).LastWriteTime).First()

EDIT : The expression I gave will sort files by last write time, meaning that if one of the files was modified, then the recent file will be the modified file. Which wasn’t the use case I wanted.

The expression to use in this case (If you want the recent file bu creation time, not by modification time ) is :
Directory.GetFiles(pathDownloads).OrderByDescending(Function(f) New FileInfo(f).CreationTimeUtc).First()


#12

can you tell me where i have to give this expression.


#13

You have to put it in a variable


#14

Hi.

I am trying to read recently generated excel file. I have created variable and given expression to that variable like “Directory.GetFiles(downloads).OrderByDescending(Function(f) New FileInfo(f).LastWriteTime).First()”.
and in read range activity , i am giving this variable name. I am stuck here. could you please help.


#15

Whats the error.
Could you upload the workflow?


#16

Error - CompareExcel : Value cannot be null.
Parameter name: path Main.xaml (20.1 KB)


#17

Every time i run my workflow, its generating new excel file with time stamp. so i want to read recently generated file.


#18

did you sort out this issue?
This is strange .
Please pass full path in Directory.GetFile(“FullPath”)
Its throwing when i pass variable.

Directory.GetFiles("“C:\Users\vreddapp\Desktop”").OrderByDescending(Function(f) New FileInfo(f).LastWriteTime).First()

Check now.Main (28).xaml (21.7 KB)


#19

I am able save the file in date time format each time i run the workflow. But issue is how to read the recently generated file.


#20

when i tried running the workflow i am getting this error “Read range : Object reference not set to an instance of an object.”


#21

It’s working fine for me.
Put one msg box and pass File variable to see is it taking recent file. Then you could pass to read range activity.(looks like its returning empty item)