@@ -71,7 +71,7 @@ export class IgxExcelExporterService extends IgxBaseExporter {
7171 }
7272 }
7373
74- protected exportDataImplementation ( data : IExportRecord [ ] , options : IgxExcelExporterOptions , done : ( ) => void ) : void {
74+ protected async exportDataImplementation ( data : IExportRecord [ ] , options : IgxExcelExporterOptions , done : ( ) => void ) {
7575 const firstDataElement = data [ 0 ] ;
7676 const isHierarchicalGrid = firstDataElement ?. type === ExportRecordType . HierarchicalGridRecord ;
7777 const isPivotGrid = firstDataElement ?. type === ExportRecordType . PivotGridRecord ;
@@ -133,26 +133,29 @@ export class IgxExcelExporterService extends IgxBaseExporter {
133133
134134 const rootFolder = ExcelElementsFactory . getExcelFolder ( ExcelFolderTypes . RootExcelFolder ) ;
135135 const fileData = { } ;
136- IgxExcelExporterService . populateZipFileConfig ( fileData , rootFolder , worksheetData )
137- . then ( ( ) => {
138- // Dynamically import fflate to reduce initial bundle size
139- import ( 'fflate' ) . then ( ( { zip } ) => {
140- zip ( fileData , ( _ , result ) => {
141- this . saveFile ( result , options . fileName ) ;
142- this . exportEnded . emit ( { xlsx : fileData } ) ;
143- done ( ) ;
144- } ) ;
145- } ) . catch ( ( error ) => {
146- // Handle dynamic import failure
147- console . error ( 'Failed to load fflate module:' , error ) ;
148- done ( ) ;
136+ try {
137+ await IgxExcelExporterService . populateZipFileConfig ( fileData , rootFolder , worksheetData ) ;
138+
139+ // Dynamically import fflate to reduce initial bundle size
140+ const { zip } = await import ( 'fflate' ) ;
141+
142+ await new Promise < void > ( ( resolve , reject ) => {
143+ zip ( fileData , ( error , result ) => {
144+ if ( error ) {
145+ reject ( error ) ;
146+ return ;
147+ }
148+ this . saveFile ( result , options . fileName ) ;
149+ this . exportEnded . emit ( { xlsx : fileData } ) ;
150+ resolve ( ) ;
149151 } ) ;
150- } )
151- . catch ( ( error ) => {
152- // Handle populateZipFileConfig failure
153- console . error ( 'Failed to populate zip file config:' , error ) ;
154- done ( ) ;
155152 } ) ;
153+
154+ done ( ) ;
155+ } catch ( error ) {
156+ console . error ( 'Excel export failed:' , error ) ;
157+ done ( ) ;
158+ }
156159 }
157160
158161 private saveFile ( data : Uint8Array , fileName : string ) : void {
0 commit comments