---
title: excel (DataFrameWriter)
description: "DataFrameWriter.excel method in PySpark: Saves the content of the DataFrame in Excel format at the specified path."
canonical_url: https://docs.databricks.com/gcp/en/pyspark/reference/classes/dataframewriter/excel
---

# excel (DataFrameWriter)

Saves the content of the `DataFrame` in Excel format at the specified path.

## Syntax

```
excel(path, mode=None, dataAddress=None, headerRows=None)
```

## Parameters

| Parameter     | Type                 | Description                                                                                                                                     |
| ------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `path`        | str                  | The path in any Hadoop-supported file system.                                                                                                   |
| `mode`        | str, optional        | The behavior when data already exists. Accepted values are `'append'`, `'overwrite'`, `'ignore'`, and `'error'` or `'errorifexists'` (default). |
| `dataAddress` | str, optional        | The address of the data in the Excel file.                                                                                                      |
| `headerRows`  | int or str, optional | The number of header rows.                                                                                                                      |

## Returns

None

## Examples

Write a DataFrame into an Excel file and read it back.

```python
import tempfile
with tempfile.TemporaryDirectory(prefix="excel") as d:
    spark.createDataFrame(
        [{"age": 100.1, "name": "Alice"}]
    ).write.excel(d, mode="overwrite", headerRows=1)

    spark.read.option("headerRows", "1").excel(d).show()
    # +-----+------------+
    # |  age|        name|
    # +-----+------------+
    # |100.1|Alice|
    # +-----+------------+
```
