How to get information from excel if I do not know name of sheet and how many columns

Dear experts,

please provide some idea for next situation:
I will download excel files. I do not know name of files, name of sheet and how many columns will be in those files. I should check if files contain some key word in any columns inside.

Thank you for support and ideas! :slight_smile:


Refer this


Hi @Aggi,

use the below code to get the download path and store it into string variable(strpath)
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"\Downloads" **or** Environment.ExpandEnvironmentVariables("%USERPROFILE%\Downloads")

strXLFilePath=Directory.GetFiles(folderlocation, “*.xlsx”)(0)

use Excel Application scope to read the sheet. (Refer the below path how to get the sheet names)

Then use Read Range to get the data from the excel.



Can some one please explain what does (0) at the end of the above Expression mean?

I tried the code without (0) and it would not let me assign it to a String variable since it was Expecting a String array

i used (0) then and it resolved the issue.

Your Explanation on this will be very valuable.

Thanks in Advance!


Hi @Rajiv_Mulchandani,

Directory.GetFiles will return the value of array.

Here (0)-> it’s means first value of the array value.

(0)-> it means the first sheet.

Regards, Arivu :slight_smile:

1 Like

Hi Arivu,

Thankyou for your Explanation!

That was very helpful. It Resolved my query and now i understand it just perfect.