Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Rename and Delete Sheet Name in Excel

KamenRider
11 - Bolide

Hi,

 

I have an excel attached which consist of two tabs. I would like to rename "Summary" into "Controller" and delete the "Data" sheet.

 

I hope someone there will show and help me to do this.

 

Thanks,

Kamen

26 REPLIES 26
KamenRider
11 - Bolide

Anyone please...

nagakavyasri
12 - Quasar

You can use 'Overwrite file(Remove)' option to replace the file as deleting a sheet is not possible.

 

Capture.PNG

flying008
15 - Aurora

Hi, @KamenRider 

 

FYI.

 

KamenRider
11 - Bolide

Hi @flying008 @nagakavyasri 

 

Thanks for the response. While your ideas work, I forgot to include in the file the condition that it should retain or preserve its formatting. I have once again save a sample file with format.

 

Also, I notice a quotation on the tab name. Can we remove it? Can you state your formula here again, i noticed something in the formula which I cant get.

 

Controller.PNG

Hope to hear from you guys and from anyone who would like to share their ideas. I need to solve this case for the project.

 

Thanks

Kamen

Swathi
9 - Comet

Can you try clicking Preserve formatting on Overwrite in the output tool

flying008
15 - Aurora

Hi, @KamenRider 

 

1-  You didn't read my post carefully.

 

 

Replace([FileName], '`Summary$`', 'Controller')

 

 

 

2- If you want to retain all format of sheet, maybe you need use python tool to save the case, like below code:

 

 

import openpyxl
import os

# Defind file path
ABC = "D:\abc\Rename and Delete.xlsx"

# Open Excel File
workbook = openpyxl.load_workbook(ABC)

# delete Sheet 
if "Data" in workbook.sheetnames:
    workbook.remove(workbook["Data"])

# Rename Sheet
if "Summary" in workbook.sheetnames:
    worksheet = workbook["Summary"]
    worksheet.title = "Controller"

# Save File
workbook.save(ABC)

# Close File
workbook.close()

 

KamenRider
11 - Bolide

Hi @Swathi  Yes I did but nothing happen. It did not retain the format.

 

Kamen

KamenRider
11 - Bolide

Hi @flying008 

 

Thank you for writing the formula since I get confuse with the punctuation you use with "Summary". Having it copy - paste fix the problem.

 

In line to the python code, can you help me how I am going to enter it in Alteryx? I still building my knowledge with Alteryx and especially not a coder expert.

 

I do hope this will solve the problem. Looking forward for your response and assistance.

 

Thanks,

Kamen

KamenRider
11 - Bolide

Hi @Swathi @nagakavyasri @flying008 

 

Have used the Python tool using the code provided. Having a hunch of using it which I hope I am doing it right. See below errors I've got. I hope you could help me debug the error since I have zero knowledge in using python.

 

python.PNG

Thanks

Kamen

Labels
Top Solution Authors