How to read the different sheet names in excel

hello,

im trying to read the sheet names in excel

Do you want to read the Data inside different sheets or you want the names of the sheets?

names of the sheets and data of the sheets aslo

This might help! Also can you tell me what are names of sheets?

1 Like

Hello @sundeeperanti

Check out this workfow i made for you :slight_smile:
Just change the file path and run :slight_smile:
SheetNames.xaml (8.8 KB)

Remove ā€˜Read Rangeā€™ if you only want names :slight_smile:

2 Likes

thanks @Rishabh_Lakhera

1 Like

Yes!
I do not want to convert all worksheets to pdf files.
I want to check data inside every worksheets and convert some worksheets.

Hi @Rishabh_Lakhera
I tried your solution, works fine while extracting the sheet name but further when i am trying to read the text for that sheet, i get the below error, please can you assist.
image

Are you trying to add a column?
Can you show me your workflow?
How are you extracting the value?

Hi,
Below is my workflow for Excel application scope,If it is not clear i will create a similar one and attach it.
I am not trying to add any column, i just want to read the data for each sheet name, so i have put the Read range in the for loop.
image.
The error comes in Read range.

2nd doubt i have is that why the excel application scope is opening the xcel file in background, what if i donā€™t want it to be opened in background!

Hi!
If you donā€™t want the excel to work in background you can tick the visible property!
The error in read range is because you are using the same data table again and again for every sheet!
You will need to set it as new DataTable using an assign activity inside the sheetname for loop!


datatble
I hope this works :slight_smile:

SheetNames (1).xaml (9.7 KB)

I have made the necessary changes!

Change the type of ā€œfor eachā€ activity from object to string from the properties pane!

As for the second question, uncheck the ā€œvisibleā€ property from the properties pane of ā€œexcel scope applicationā€ activity!

This should work :slight_smile:

HI @Niket_Ghai @Rishabh_Lakhera,
I am still getting the same error,
image
image

I am using the variable ExcelText and assigning new table to it and iterating for every new sheet name, still i get the same error and i also tried changing the type of ā€œfor eachā€ activity from object to string.
May be i am doing some stupidity:-(

Try ExcelText = New System.Data.DataTable

Could you attach the xaml file please?

SheetNames (1).xaml (10.4 KB)

Working for me :slight_smile:
Try this workflow and check if this also gives the same error

Thanks @Niket_Ghai and @Rishabh_Lakhera.for your prompt replies.
The solution works perfectly for .xls and .xlsm files but i get same error for .xlsx files
.I hope the excel application scope is applicable for .xls,.xlsx as well as .xlsm files to.
Also, the bot by default reads the hidden sheet names as well, is there a way i can tell the bot not to read the hidden sheets?

What error does it gives when working with .xlsx files?

Same, as i was getting earlier
image
but i t works fine with .xls and .xlsm.