from openpyxl import Workbook
workbook = Workbook()
# create xls workbook sheet
workbook.create_sheet(index=0, title='Sheet1')
workbook.create_sheet(index=0, title='Sheet2')
# remove xls workbook sheet
workbook.remove(workbook['Sheet2'])
# get active work sheet
work_sheet = workbook.active
data = [
['Naveen', 'M', 'Software Engineer'],
['David', 'N', 'Designer'],
['Shera', 'H', 'Web Developer']
]
rows = 3
cols = 3
# iterate to set data
for row_num in range(0, rows):
for col_num in range (0, cols):
work_sheet.cell(
row=row_num + 1,
column=col_num + 1
).value = data[row_num][col_num]
# save data to xls file
workbook.save('output.xlsx')