Hope to optimize pd.ExcelWriter mode
The following code can be implemented to override the sheet and update the specified sheet separately

```python
import pandas as pd
import openpyxl

def to_sheet(df,file,sheet_name):
    wb = openpyxl.load_workbook(file)
    if sheet_name in wb.sheetnames:
        sheet = wb[sheet_name]
        wb.remove(sheet)
    wb.save(file)
    
    with pd.ExcelWriter(file,mode='a',engine='openpyxl') as excel:
        df.to_excel(excel,sheet_name=sheet_name,index=False) 
```  

Hope to optimize pd.ExcelWriter mode