I have a pandas dataframe df which I want to overwrite to a sheet Data of an excel file while preserving all the other sheets since other sheets have formulas linked to sheet Data
I used the following code but it does not overwrite an existing sheet, it just creates a new sheet with the name Data 1
with pd.ExcelWriter(filename, engine="openpyxl", mode="a") as writer:
df.to_excel(writer, sheet_name="Data")
Is there a way to overwrite on an existing sheet?