How to get the Sheet name from Excel

That is not an activity.
You need to use an output Workbook variable in Excel Application Scope and then use wb.GetSheets
See attached.

Sheets.xaml (5.6 KB)

6 Likes

Studio 2016.1.6137, Excel activities 1.2.6123.30845, this still throws an NRE.

Attached sample - working part and throwing an NRE. The bug that Corneliu was talking about earlier is still there.

ExcelTest.xaml (12.4 KB)

5 Likes

I have the nu package to use but don’t know if I can share it in here. this will allow you to use sheetlist function to get all the names.

From technical point of view, you can (or if you can’t add it as an attachment due to user restrictions or something similar, you could upload it somewhere and post a link, or post the code to pastebin etc.).

1 Like

The WoorkbookApplication variable is an OutArgument and right now it is created when the activity is completed. This is why you have to use it outside the Excel Application Scope.

We will fix this in a future release.

3 Likes

Dear all:

I have a solution for y’all.

First, install this package.

ExcelActivities.1.0.18.nupkg (9.5 KB)

Second: open this xaml and set up the path to an excel workbook with more than one sheet.
Readsheetname.xaml (7.7 KB)

Please, please comment your findings on this.

Hello,
Can anyone please help me to know how to move the excel sheet to another workbook.

@Uma,
What about Read Range of the sheet to a datatable variable, then Write Range with that variable to the other file?

I’m sure there are a few other coding methods too.

Thanks.

1 Like

No i want to move the sheet only which not having any data.and i am moving that sheet which is just template and i want to move this sheet into tge another workbook.
Thanks

Can you have the sheet in a file by itself? Then you can use the “Copy File” Activity to use the template with other datatables.

EDIT: Or, have a template with all the sheets you need, then like I said use Copy File and Write Range to the copied file to those sheets you want.

My template file only have the sheet(that having the format only)and i want to add this sheet into my anther workbook.supppse my one wb contains sheet 1and i wanto add this sheet 1into my another workbook.

I want to do same as option of excel move or copy .
Thanks

Can you copy the sheet to another Workbook and delete exisiting sheet?

image

My Excel sheet is protected and sent in eMail. I am downloaded and trying to read data when com exception is displayed. Is there alternate way to get sheet name

Hello,

can you please share me the document how you made the package procedure.

1 Like

It’s there… haha just right click and save as.

To get the Sheet Name follow the steps.

Step 1 : Insert activity Excel Application Scope and enter file path (with extension).

Step 2 : Create variable workbook with variable type UiPath.Excel.WorkbookApplication

Step 3 : Set properties Output : workbook

Step 4 : Create variable sheetName with variable type String

Step 5 : Insert activity Assign and assign workbook.GetSheets(0) to variable sheetName
sheetName = workbook.GetSheets(0)

Step 6 : Set properties To : sheetName and Value : workbook.GetSheets(0)

you will get the first sheet name in sheetName variable

5 Likes

this is the solution

1 Like

2 years passed, and this is still not solved…

Above solution is given for counting no of excel sheets.

How can we get name of sheets in an excel ?