danfo.toExcel
Converts a DataFrame or Series to Excel file, and write file to disk or download in browser.
Last updated
Converts a DataFrame or Series to Excel file, and write file to disk or download in browser.
Last updated
danfo.toExcel(data, options)
The toExcel function can be used to write out a DataFrame or Series to Excel (.xlsx) file. The output format will depend on the environment. In the following examples, we show you how to write/download an Excel file from Node and Browser environments.
You can write a DataFrame or Series in Excel format using the toExcel function and specifying the file path.
You can automatically convert and download an Excel file in a browser environment, by specifying a filename. This will open a download window.
Parameters
Type
Description
Default
data
Series or DataFrame
The Series or DataFrame to write to CSV
options
object, optional
Configuration object:
{
filePath
: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version
fileName
: The name of the file to download as. Only needed in the browser environment.
sheetName
: Name to call the excel sheet.
writingOptions: Supports all xlsx write options. See https://docs.sheetjs.com/docs/api/write-options
}
{ filePath: "./output.xlsx", sheetName: "Sheet1" }