Longwinded question, I know.
But all solutions I have tried either delete all the sheets and replace them with one sheet containing my dataframe or breaks the excel file and requires excel to repair it.
Would be interested to know what the 'best' way to achieve this will be.
Here is how i write data frame to excel file, after quick search I found here how u can delete certain sheet - https://www.pythonexcel.com/delete-sheet.php
import pandas as pd from openpyxl import load_workbook
writer = pd.ExcelWriter(b, engine='xlsxwriter')
df = pd.DataFrame({"q3": [""],
"q2": [""],
"q1": [""]})
writer = pd.ExcelWriter(b, engine='xlsxwriter')
df.to_excel(writer, sheet_name='Sheet1', index=False)
writer.save()
`
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.