Regression in to_excel when setting duplicate column names
- [x] closes #39695
- [x] tests added / passed
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing.html#code-standards) for how to run them
- [x] whatsnew entry

Changes LGTM.  Restarted CI on failed build since it looks unrelated. thanks @phofl  @meeseeksdev backport 1.2.x