Home

Published

- 1 min read

pandas to excel add another sheet in existing excel file

img of pandas to excel add another sheet in existing excel file

The solution for this is noted below

pandas to excel add another sheet in existing excel file

Solution

   import pandas as pd
from openpyxl import load_workbook
 
FilePath = "your excel path"
ExcelWorkbook = load_workbook(FilePath)
writer = pd.ExcelWriter(FilePath, engine = 'openpyxl')
writer.book = ExcelWorkbook
df.to_excel(writer, sheet_name = 'your sheet name')
writer.save()
writer.close()

Try other methods by searching on the site. That is if this doesn’t work