pandas.io.formats.style.Styler.to_excel

pandas 3.1.1 · Input and output · method

Write the receiver to an Excel sheet. Use ExcelWriter to manage multiple sheets in one workbook.

Call syntax

Styler.to_excel(…) Full signature
Styler.to_excel(
    excel_writer,
    sheet_name='Sheet1',
    na_rep='',
    float_format=None,
    columns=None,
    header=True,
    index=True,
    index_label=None,
    startrow=0,
    startcol=0,
    engine=None,
    merge_cells=True,
    encoding=None,
    inf_rep='inf',
    verbose=True,
    freeze_panes=None,
    storage_options=None,
    autofilter=False,
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
excel_writer Required
Positional or keyword
path-like, file-like, or ExcelWriter object

Provide an output workbook writer or file destination.

sheet_name Optional
Positional or keyword
Default 'Sheet1'
str

Choose worksheets by name or zero-based position. None requests every sheet where supported.

na_rep Optional
Positional or keyword
Default ''
str

Choose the text used to display missing values.

float_format Optional
Positional or keyword
Default None
str

Provide a format string or callable to control numeric display.

columns Optional
Positional or keyword
Default None
sequence or list of str

Supply column labels or control how columns are handled.

header Optional
Positional or keyword
Default True
bool or list of str

Define which row or rows provide column names, or control whether to write them.

index Optional
Positional or keyword
Default True
bool

Supply row labels or control how existing row labels are used.

index_label Optional
Positional or keyword
Default None
str or sequence

Choose the column heading written for row index values.

startrow Optional
Positional or keyword
Default 0
int

Set the zero-based first row of the written worksheet region.

startcol Optional
Positional or keyword
Default 0
int

Set the zero-based first column of the written worksheet region.

engine Optional
Positional or keyword
Default None
str

Choose the implementation that performs the operation.

merge_cells Optional
Positional or keyword
Default True
bool or 'columns'

Choose whether grouped header labels should occupy merged Excel cells.

encoding Optional
Positional or keyword
Default None
str or None

Name a text encoding such as "utf-8".

inf_rep Optional
Positional or keyword
Default 'inf'
str

Choose the written representation for infinite numeric values.

verbose Optional
Positional or keyword
Default True
str

Request more detailed diagnostic output where supported.

freeze_panes Optional
Positional or keyword
Default None
tuple of int (length 2)

Provide the Excel pane location to keep the specified rows or columns visible.

storage_options Optional
Positional or keyword
Default None
dict

Pass storage-backend options such as connection settings or HTTP headers.

autofilter Optional
Positional or keyword
Default False
bool

Returns

None