# Manipulate tabs inside an excel

**URL:** <https://forum.knime.com/t/manipulate-tabs-inside-an-excel/14492>\
**Category:** KNIME Analytics Platform\
**Created:** [March 22, 2019, 7:52pm UTC](https://forum.knime.com/t/manipulate-tabs-inside-an-excel/14492 "2019-03-22T19:52:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dataNinja](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dataNinja](https://forum.knime.com/u/dataNinja)\
**Post date:** [March 22, 2019, 7:52pm UTC](https://forum.knime.com/t/manipulate-tabs-inside-an-excel/14492/1 "2019-03-22T19:52:19Z")

</div>

Hi experts, this is a beginner question since I couldn’t find this in Google and/or in the documentation. Can you let me know if KNIME has node(s) that can achieve below?

1. Rename a specific tab inside an excel file
2. Copy/duplicate a specific tab inside an excel file

Thanks for your help.  
Best,  
Tom

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [March 24, 2019, 2:58pm UTC](https://forum.knime.com/t/manipulate-tabs-inside-an-excel/14492/2 "2019-03-24T14:58:54Z")

</div>

You can do several manipulations for Excel with the Python library [openpyxl](https://openpyxl.readthedocs.io/en/stable/). Please keep in mind that the syntax is not super easy and I encountered some quirks (they may or may not have to do with doing it on a Mac)

 ![image](https://forum-cdn.knime.com/uploads/default/original/2X/0/02d0a3f01e6cfb769d27571fe545cfd3a5f4a586.png)

[kn\_example\_python\_excel\_manipulate.knar](https://forum-cdn.knime.com/uploads/default/original/2X/b/b0418b772817b4efd0ff38c436215a9c7de0a38d.knar) (57.1 KB)

Also the [concept of Continental](https://www.knime.com/blog/empower-your-own-experts-continental-wins-the-digital-leader-award) to spread the use of KNIME within the company is bearing some fruit, although I have not (yet) seen Excel Data manipulation nodes, but you already can do a lot of things with their nodes.

> **[Continental Nodes for KNIME — XLS Formatter Nodes | KNIME](https://www.knime.com/community/continental-nodes-for-knime-xls-formatter)**

## Example how to rename an existing Excel sheet

```
# https://openpyxl.readthedocs.io/en/stable/tutorial.html#loading-from-a-file

# conda install -c anaconda openpyxl

from openpyxl import load_workbook
import openpyxl
import os

var_data_path = flow_variables['v_path_data_folder']
print("var_data_path : ", var_data_path )

var_path_excel_file = var_data_path + os.path.sep + "my_data.xlsx"
print("var_path_excel_file : ", var_path_excel_file )

var_old_sheet_name = 'data'
var_new_sheet_name = 'data_new'

wb = load_workbook(var_path_excel_file)

ws = wb[var_old_sheet_name]

# activate the ws 'data'
for s in range(len(wb.sheetnames)):
    if wb.sheetnames[s] == ws:
        break
wb.active = s

v_list_sheetnames = wb.sheetnames
print(v_list_sheetnames)

for i in v_list_sheetnames:
	if i == var_new_sheet_name:
		# wb.active = i
		wb.remove_sheet(var_new_sheet_name)

ws.title = var_new_sheet_name

v_list_sheetnames = wb.sheetnames
print(v_list_sheetnames)

wb.save(var_path_excel_file)

output_table = input_table.copy()
```

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 23, 2023, 8:33pm UTC](https://forum.knime.com/t/manipulate-tabs-inside-an-excel/14492/3 "2023-06-23T20:33:12Z")

</div>


