xlsx()
Exports data from a grid to an Excel file
info
DHTMLX Grid uses the WebAssembly-based library Json2Excel for export of data to Excel. Check the details.
xlsx(config?: IXlsxExportConfig) => Promise<void>;
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) set as"../libs/json2excel/1.3/worker.js?vx", if the local export server is used. The path to the public export server is used by defaultname?: string- (optional) "grid" by default. The name of a ready Excel filetableName?: string- (optional) "data" by default. The name of a sheet with grid data in the Excel filedateFormatMask?: string- (optional) "dd/mm/yy" by default. The mask used for dates formatting in Excel
note
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/1.3/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