README
Excel Export Service
@slickgrid-universal/excel-export
Simple Export to Excel Service that allows to exporting as .xls
or .xlsx
.
Internal Dependencies
External Dependencies
This package requires excel-builder-webpacker which itself requires jszip and lodash, the later not being a small lib, so make sure that you are fine with the bundle size. For our use case, the extra bundle size is totally worth the feature.
Installation
Follow the instruction provided in the main README, you can see a demo by looking at the GitHub Demo page and click on "Export to Excel" from the Grid Menu (aka hamburger menu).
Usage
In order to use the Service, you will need to register it in your grid options via the registerExternalResources
as shown below.
ViewModel
import { ExcelExportService } from '@slickgrid-universal/excel-export';
export class MyExample {
initializeGrid {
this.gridOptions = {
enableExcelExport: true,
excelExportOptions: {
sanitizeDataExport: true
},
registerExternalResources: [new ExcelExportService()],
}
}
}
If you wish to reference the service to use it with external export button, then simply create a reference while instantiating it.
import { ExcelExportService } from '@slickgrid-universal/excel-export';
export class MyExample {
excelExportService: ExcelExportService;
constructor() {
this.excelExportService = new ExcelExportService();
}
initializeGrid {
this.gridOptions = {
enableExcelExport: true,
excelExportOptions: {
sanitizeDataExport: true
},
registerExternalResources: [this.excelExportService],
}
}
exportToExcel() {
this.excelExportService.exportToExcel({ filename: 'export', format: FileType.xlsx });
}
}