I've been searching for a way to do the following:
Open an existing workbook that contains several worksheets,
.xlsl
.Create a new worksheet, and rename it.
Copy data and formatting from an existing worksheet, named 'Template', and paste that data to the previously created worksheet.
Is there any way to do what I need?
EDIT: This is the way how to do it:
import openpyxl
from openpyxl.worksheet.copier import WorksheetCopy
workbook = openpyxl.load_workbook('input.xlsx')
template_worksheet = workbook.get_sheet_by_name(sheet_name)
new_worksheet = workbook.create_sheet('New_Sheet_Name')
instance = WorksheetCopy(template_worksheet, new_worksheet)
WorksheetCopy.copy_worksheet(instance)
workbook.save('output.xlsx')