I have a dataframe df where i want to change the header background color, apply borders and save it excel file in .xlsx extension.
I have tried styleframe, some functionalities in openpyxl and tried to write udf s, But nothing seemed to work.
I have a dataframe df where i want to change the header background color, apply borders and save it excel file in .xlsx extension.
I have tried styleframe, some functionalities in openpyxl and tried to write udf s, But nothing seemed to work.
Here is the solution using StyleFrame package that you mentioned.
import pandas as pd
from styleframe import StyleFrame, Styler, utils
df = pd.DataFrame({'a': [1, 2, 3], 'b': [1, 2, 3]})
sf = StyleFrame(df)
sf.apply_headers_style(styler_obj=Styler(bold=True,
bg_color=utils.colors.green,
border_type=utils.borders.medium))
sf.to_excel('output.xlsx').save()
I would recommend you to make sure that you have the lastest version of StyleFrame installed.
pip install -U styleframe