Skip to content

BeautifulExcel

⚠️🏗️️ Note: This is only the first version - actively working on additional features!

BeautifulExcel is a python package that makes it easy and quick to save pandas dataframes in beautifully formatted excel files. BeautifulExcel is the Openpyxl for Data Scientists with a deadline.


Pandas vs. BeautifulExcel .to_excel()

Pandas BeautifulExcel
df.to_excel(writer, sheet_name='My Output') writer.to_excel(df, sheet_name='My Output')
Article Reading View Article Reading View
Raw, unformatted data that requires lots of additional formatting. Quickly export beautifully styled table with only one line of code!


Getting it

$ pip install beautifulexcel
Update Package: (execute regularly to get the latest features)
$ pip install beautifulexcel --upgrade


How to use:

from beautifulexcel import ExcelWriter

with ExcelWriter('workbook.xlsx', mode='r', theme='elegant_blue') as writer:
    ws1 = writer.to_excel(
        df,
        sheet_name='My Sheet',
        startrow=0,
        startcol=0,
        index=True,
        header=True,
        col_autofit=True,  # automatically change column width to fit content best
        col_widths={'A': 20, 'RoE': 40},  # define column width manually
        auto_number_formatting=True,  # automatically detect number format and change excel format
        style={'RoE': 'bg_light_blue', 'D:E': {'fill': 'FFEEB7'}},  # apply custom styling to this dataframe export
        use_theme_style=True,  # apply the excel workbook "theme" set in ExcelWriter()
    )


Find out more about:

  • beautifulexcel.ExcelWriter('workbook.xlsx')


    Find out more about aguments for beautifulexcel.ExcelWriter(...)

    beautifulexcel.ExcelWriter()

  • writer.to_excel(df, sheet_name='My Sheet')


    Find out more about aguments for writer.to_excel(...)

    writer.to_excel()

  • Styling & Themes


    Change the colors, fonts, sizes, borders and more with a few lines

    Customization

  • Additional functions for sheets


    Learn more about further functions to e.g. merge cells, group columns/rows and more

    sheet1.function_a()