@@ -54,34 +54,19 @@ export class IgxExcelExporterService extends IgxBaseExporter {
5454 @Output ( )
5555 public onExportEnded = new EventEmitter < IExcelExportEndedEventArgs > ( ) ;
5656
57- private static populateFolder ( folder : IExcelFolder , zip : JSZip , worksheetData : WorksheetData ) : any {
57+ private static async populateFolderAsync ( folder : IExcelFolder , zip : JSZip , worksheetData : WorksheetData ) {
5858 for ( const childFolder of folder . childFolders ( worksheetData ) ) {
5959 const folderInstance = ExcelElementsFactory . getExcelFolder ( childFolder ) ;
6060 const zipFolder = zip . folder ( folderInstance . folderName ) ;
61- IgxExcelExporterService . populateFolder ( folderInstance , zipFolder , worksheetData ) ;
62- }
63-
64- for ( const childFile of folder . childFiles ( worksheetData ) ) {
65- const fileInstance = ExcelElementsFactory . getExcelFile ( childFile ) ;
66- if ( ! ( fileInstance instanceof WorksheetFile ) ) {
67- fileInstance . writeElement ( zip , worksheetData ) ;
68- }
69- }
70- }
71-
72- private static populateFolderAsync ( folder : IExcelFolder , zip : JSZip , worksheetData : WorksheetData , done : ( ) => void ) : any {
73- for ( const childFolder of folder . childFolders ( worksheetData ) ) {
74- const folderInstance = ExcelElementsFactory . getExcelFolder ( childFolder ) ;
75- const zipFolder = zip . folder ( folderInstance . folderName ) ;
76- IgxExcelExporterService . populateFolderAsync ( folderInstance , zipFolder , worksheetData , done ) ;
61+ await IgxExcelExporterService . populateFolderAsync ( folderInstance , zipFolder , worksheetData ) ;
7762 }
7863
7964 for ( const childFile of folder . childFiles ( worksheetData ) ) {
8065 const fileInstance = ExcelElementsFactory . getExcelFile ( childFile ) ;
8166 if ( fileInstance instanceof WorksheetFile ) {
82- ( fileInstance as WorksheetFile ) . writeElementAsync ( zip , worksheetData , ( ) => {
83- done ( ) ;
84- } ) ;
67+ await ( fileInstance as WorksheetFile ) . writeElementAsync ( zip , worksheetData ) ;
68+ } else {
69+ fileInstance . writeElement ( zip , worksheetData ) ;
8570 }
8671 }
8772 }
@@ -97,13 +82,14 @@ export class IgxExcelExporterService extends IgxBaseExporter {
9782 }
9883 }
9984
85+
10086 const worksheetData = new WorksheetData ( data , options , this . _indexOfLastPinnedColumn , this . _sort , this . _isTreeGrid ) ;
10187 this . _xlsx = new JSZip ( ) ;
10288
10389 const rootFolder = ExcelElementsFactory . getExcelFolder ( ExcelFolderTypes . RootExcelFolder ) ;
10490
105- IgxExcelExporterService . populateFolder ( rootFolder , this . _xlsx , worksheetData ) ;
106- IgxExcelExporterService . populateFolderAsync ( rootFolder , this . _xlsx , worksheetData , ( ) => {
91+ IgxExcelExporterService . populateFolderAsync ( rootFolder , this . _xlsx , worksheetData )
92+ . then ( ( ) => {
10793 this . _xlsx . generateAsync ( IgxExcelExporterService . ZIP_OPTIONS ) . then ( ( result ) => {
10894 this . saveFile ( result , options . fileName ) ;
10995 this . onExportEnded . emit ( { xlsx : this . _xlsx } ) ;
0 commit comments