Skip to content

ENH: : Add header Autofilter and optional bold via engine_kwargs in to_excel #62651

@antznette1

Description

@antznette1

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

  • Many users export DataFrames to Excel and then manually:
    • Turn on Autofilter for the header row.
    • Make the header row bold for readability.
  • This is repetitive and engine-specific (xlsxwriter/openpyxl). It would be helpful if DataFrame.to_excel() could request these behaviors directly, without requiring users to post-process the file.

Feature Description

  • Add support via engine_kwargs to toggle header Autofilter and bold styling in to_excel() for both xlsxwriter and openpyxl engines.

  • Proposed usage:
    df.to_excel( "out.xlsx", engine="xlsxwriter", # or "openpyxl" engine_kwargs={ "autofilter_header": True, "header_bold": True, }, )

  • Behavior:

    • autofilter_header=True: Apply an Autofilter over the header row and the written data range.
    • header_bold=True: Apply bold font to header row cells if they are not already styled (do not override explicit Styler/formatting).

Alternative Solutions

Users can continue manual post-processing with xlsxwriter/openpyxl directly, but it’s repetitive, adds boilerplate, and is easy to forget.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions