I am creating excel file with multiple sheets. In every sheet i need same define name with group of rows and columns.we can create it manually but through program how to achieve this.
Below is the code:
wb = openpyxl.load_workbook(file.xlsx)
shee1 = wb['sheet1']
shee2 = wb['sheet1']
wb.create_named_range('sales', shee1 , '$B$11:$B$35')
wb.create_named_range('sales', shee2 , '$B$11:$B$35')
following is the error i am getting
File "C:\Users\728355\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\workbook\workbook.py", line 319, in create_named_range self.defined_names.append(defn) File "C:\Users\728355\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\workbook\defined_name.py", line 201, in append raise ValueError("""DefinedName with the same name and scope already exists""") ValueError: DefinedName with the same name and scope already exists