xlsx()
Exports data from a grid to an Excel file
DHTMLX Grid uses the WebAssembly-based library Json2Excel for export of data to Excel. Check the details.
Parameters:
config- (optional) an object with export settings. You can specify the following settings for export to Excel:-
url?: string- (optional) the path to the worker.js file of the Json2Excel library (where export will be processed). By default,https://cdn.dhtmlx.com/libs/json2excel/next/worker.js?vxis used.For a local export server, set the path to the worker.js file relative to your server: use
"../libs/json2excel/x.x/worker.js?vx"for a specific version (replacex.xwith the version deployed on your server). -
name?: string- (optional) "grid" by default. The name of a ready Excel file -
tableName?: string- (optional) "data" by default. The name of a sheet with grid data in the Excel file -
dateFormatMask?: string- (optional) "dd/mm/yy" by default. The mask used for dates formatting in Excel
-
You can specify extended export configuration settings via the Grid exportConfig configuration property.
Returns:
A promise of data export
Example
// default export
grid.export.xlsx()
.then(() => console.log("success"))
.catch(() => console.log("failure"))
.finally(() => console.log("finished"));
// export with config settings
grid.export.xlsx({
url: "../libs/json2excel/x.x/worker.js?vx", // a local path to the `worker.js` file of the export module
name: "my_file", // the name of a ready Excel file
tableName: "grid", // the name of a sheet with grid data in the Excel file
dateFormatMask: "mm.dd.yy" // the date format mask for Excel
})
.then(() => console.log("success"))
.catch(() => console.log("failure"))
.finally(() => console.log("finished"));
Related samples: Grid. Export to xlsx and csv
Related article: Exporting Grid
Change log:
- The method returns a promise of data export since v9.3