use "pip install xls2xlsx"
import pandas as pd
df = pd.read_excel()
>>> df
User Name Country City Gender Age
0 Forrest Gump USA New York M 50
1 Mary Jane CANADA Tornoto F 30
2 Harry Porter UK London M 20
3 Jean Grey CHINA Shanghai F 30
df.to_excel('saved_file.xlsx')
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')