I met the same and when openpyxl is changed to xlsxwriter, it works fine
with pd.ExcelWriter(filename, engine='xlsxwriter', mode='w') as writer: