How to read sheet name of an excel file

uiautomation
activities

#1

Hello I want to read sheet name of an excel file .

I am unable to understand example How to get the Sheet name from Excel

hence want guidance in simple terms


How to read all sheets in a excel file
Reading xlsx file
#2

Hello @piyush.2224

Firstly you have to use “Excel application scope” activity to get the workbook from your excel file.

Then, you can obtain all the sheets names of the excel with workbook.GetSheets.


Get List of Visible/Active worksheets in Excel
#3

Hey @piyush.2224

please find following sample attached workflow and let me know :slight_smile:

Sheets.xaml (6.9 KB)

Regards…!!
Aksh


Check sheet name ( exists )
How to use wildcard in a string
How to Get already opened Excel
#4

In the above solution,I think the typearguement in For each loop should be string

Sheets.xaml (6.9 KB)


ExcelのSheet名の取得
Writing into excl
#5

Yeah… 2 month ago was working with other things with workbook object. so forgot to change it here . but edited.

Regards…!!


#6

I assumed that. Not seeing you much around these days, seem to be busy?


#7

@vvaidya Yeah kind of trying new things and workload… :frowning:

What about you?..


#8

Work Load will begin from May (a lot) so will be in your shoes then.


#9

haha … now just trying something nasty :stuck_out_tongue: So :smiley: Lets see what future is holding with it for me lol :slight_smile:


#10

i need to get the hidden sheet names in the excel workbook…what should i do


#11

Hey @niridi

You can also get the hidden sheet name as well form Excel Workbook Object.

Test.xlsx (10.9 KB)

hidden sheet.xaml (6.9 KB)

IN the above excel Sheet2 and Sheet6 are hidden.
when you will run the sample still u will be able to get those sheet name with other visible sheet name as well.

Regards…!!
Aksh


How to read the different sheet names in excel
#12

its working good :slight_smile:

thanks!!!


#13

i want to get only the hidden sheet name instead of getting all the sheets in the workbook


#14

The example you provided is not working. I’m getting following error: : Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Microsoft.Office.Interop.Excel.Worksheet’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{000208D8-0000-0000-C000-000000000046}’ failed due to the following error: En sådan grænseflade understøttes ikke (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

What is the solution of getting all sheets names within a workbook?


#15

@aksh1yadav do you happen to know how we can get around this issue posted by @Ohrid?
I believe, in my case, it is because the Excel file has a Chart on a sheet.

Excel Package Version 2.3.6682.26635
I tried reinstalling the Excel package and am on the most recent.
I have tried multiple machines and with admin rights.

I am using wb.GetSheets() when the error occurs.

If there isn’t a known solve for this, I will escalate it to UiPath Support.

Regards.

C


#16

Hi @ClaytonM,
Can you try this “WorkBook.GetSheets.ToList()” .

Below It has the example

Regards
Balamurugan


#17

Thanks, adding .ToList didn’t help.
It only happens when there is a Chart as one of the sheets.


#18

Hi @ClaytonM,
If possible , can you share the source.

Regards
Balamurugan


#19

I reproduced issue with a new file:

image

Excel file with Chart on a New Sheet: test1.xlsx (11.3 KB)

Thanks.


#20

Hi @ClaytonM,
Yes. You are right. It is giving error only to have the chart. It doesn’t have cells only the chart . I copied chart into another excel file. And tried to get the sheets count . It is working.

Regards
Balamurugan