Rename a sheet in workbook

I need to rename a sheet in workbook

Please help!!!

1 Like

Hope this would help you resolve this

Cheers @RachelN

I cant use hot keys as am using workbook

and also invoke code is not supporting

Rename worksheet by BalaReva is showing the below error
image

Please help @palaniyappan

Hi @RachelN,

You use this activity to rename sheet exists in the UiPath Go .

Regards
Balamurugan.S

1 Like

Hey @RachelN

You can use an existing thread to achieve this :slight_smile:

Rename Single Excel Sheet

Regards…!!
Aksh

1 Like

Can you try using this activity @RachelN

image

1 Like

I have installed this custom activity and tried but getting the error
image

@balupad14

1 Like

I want to use workbook not excel @HareeshMR

I tried invoke code but getting error


@aksh1yadav

Can you check the sheet name is exists. can you show me the properties of the activity.

Regards
Balamurugan.S

Hi @RachelN

Just check my attached example and see how you have to mention arguments to pass and take values from invoke Code.

Regards…!!
Aksh

New sheet Name=“08-2019”
Sheetname=“Sheet1”
File path- Existing file path

1 Like

Hi ,
I have sent you sample file.

Regards
Balamurugan.S

i changed the file path to my file path and ran the sequence. It ran without any error but the sheet name was not changed.

Please help me on this @aksh1yadav

here is the code

I changed only the file path

Hey @RachelN

Check your existing Sheetname is Sheet1 or Sheet 1?

Regards,!!
Aksh

Sheet1 only @aksh1yadav

I dont have excel installed in my system
Am using workbook only @aksh1yadav

My Sample requires Excel to be installed.

Regards…!!
Aksh

Please suggest me some other option to rename the sheet using workbook(libre office)
@aksh1yadav

@RachelN

If you do not have excel installed on your computer, use the ClosedXML.

First you need to get the right import. Go to the import tab and search for ‘ClosedXML.Excel’

Then get the worksheet names in an invoke code:

workbook = New XLWorkbook(Filename.Trim)
worksheetnames = New List(Of String)()

For Each worksheet In workbook.Worksheets
worksheetnames.Add(worksheet.Name)
Next

Arguments are:

  1. workbook - in - XLWorkbook
  2. worksheet - in - IXLWorksheet
  3. gc - in - GC
  4. Filename - in - string
  5. worksheetnames - out - list of string

Then you can use another invoke code to change the sheet name:

workbook = New XLWorkbook("C:\Users\Downloads\Book1.xlsx")
worksheet = workbook.Worksheet("Sheet1")
worksheet.Worksheet.Name = "Sheet2"
workbook.Save()

Arguments are:

  1. workbook - in - XLWorkbook
  2. worksheet - in - IXLWorksheet

You can reference this GitHub if you need anymore examples - https://github.com/ClosedXML/ClosedXML/wiki

1 Like