I have DataFrame df.
I have Excel file template_with_styles.xlsx in which there is a color table ready.
I want to write df to a template.
from openpyxl.utils.dataframe import dataframe_to_rows
wb = load_workbook('template_with_styles.xlsx')
ws = wb.active
for r in dataframe_to_rows(df, index=None, header=True):
ws.append(r)
wb.save('my.xlsx')
As a result, I get: first comes my table with styles, and below is the data without styles.
How can I write DataFrame to a Ecxel using a prepared template?