Merk
Tilgang til denne siden krever autorisasjon. Du kan prøve å logge på eller endre kataloger.
Tilgang til denne siden krever autorisasjon. Du kan prøve å endre kataloger.
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.
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|
# +-----+------------+