Same sheet name as excel name

Hi,
I have a exel file, and I have single excel file in a folder but the name of the excel is dynamic, and the excel file name and sheet name is same always.

Like If I have excel file name is Aug11_Aug30.xlsm, It has the same sheet name Aug11_Aug30

so how to reasd the excel file name and store in a variable so that I can pass that variable in the read range excel file.

Note. I am not using any loop here. I am just reading the single sheet only. So is it possible to get the excel file name in the case of single sheet. @Palaniyappan @HareeshMR

1 Like

If you have a single file, retrieve it using Directory.Getfiles(“path”) and get the excel name as
filename = stringArray(0)

and use split activities to get the sheet name as

(filename.split("\“c).Last()).Split(”."c).First() @balkishan

1 Like

Yeah bro, I did this in this way.
Thanks
image

1 Like

@balkishan :+1: great going bro :slight_smile:

@balkishan Use below code and check.

To get file path along with extension.
Directory.GetFiles(“path”,"*.xlsm")(0)

To get only filename with extension.
Path.GetFileName(Directory.GetFiles(“path”,"*.xlsm")(0))

To get only filename without extension.
Path.GetFileNameWithoutExtension(Directory.Getfiles(“path”,"*.xlsm")(0))

Hi
Hope these steps could help you resolve this
—use a assign activity like this
Out_filepath = Directory.Getfiles(“yourfolderpath”,”*.xlsx”)
Where out_filepath is a string array variable
—then use another assign activity and mention like this
Out_excelfilepath = Out_filepath(0).ToString
—and pass this Out_excelfilepath string variable as input to excel application scope and inside the read range mention as
Split(Out_excelfilepath(0),”.”)(0).ToString

Simple isn’t it

Cheers @balkishan

1 Like

Thanks @Palaniyappan This one one is also nice solution.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.