syncfusion/ej2-javascript-ui-controls

Grid excel export as blob

Hellogark opened this issue · 4 comments

I'm working with ejs-angular and cordova.
I'm trying to export a grid to excel but i can't get the blob file to save it in a mobile device.
I do this to get the blob from pdf export

 public firstGridPdfExport: Promise<Object>; 
 public pivotGridObj: PivotView;
this.firstGridPdfExport = this.pivotGridObj.grid.pdfExport({}, true);

 this.firstGridPdfExport.then(async (pdfData: any) => {
            let {blobData} = await pdfData.save();
              this.saveMobileFile('Export.pdf',blobData,'application/pdf'); 
          });

But excel export doesn't return a blob, only returns an object with styles array and worksheets array.

This is how i generate de file

 this.firstGridExcelExport = this.pivotGridObj.grid.excelExport({}, null,null,true);
          this.firstGridExcelExport.then(async (excelData: any) => {
            //excelData returns   {  styles: [...], worksheets: [...] }
              let {blobData} = await excelData.save(); //Doesn't have a save function
              this.saveMobileFile('Export.xls',blobData,'application/xls'); 
          });

Is there a way to get the blob file? Because i've been searching and the blob generation happens internaly when the excel is beign generated.
I'm using ej2-angular-pivotview 17.4.43

<style> </style>

Hi Customer,

 

Kindly use the “excelExportComplete” event to get blob data while excel exporting. Please refer the following code example.

 

Code Example:

excelExpComplete(args: ExcelExportCompleteArgs) {     args.promise.then((e: { blobData: Blob }) => {       console.log(e.blobData);     });   }   ngOnInit(): void {     document.getElementById('export').onclick = () => {       this.pivotObj.grid.excelExportComplete = this.excelExpComplete.bind(this);       this.pivotObj.excelExport(null, null, null, true);     };   }

 

Meanwhile, we have prepared a sample for your reference.

 

Sample: https://stackblitz.com/edit/angular-9v14aq?file=app.component.ts

 

Please let us know if you need further assistance with this.

 

Regards,

Manikandan

indeed excelExportComplete works in stackblitz but is deprecated and is not working for me, i'm getting
{name: "excelExportComplete"} as args and i'm getting this error Uncaught (in promise): TypeError: Cannot read property 'then' of undefined

Hi Customer,

We have checked the reported problem and we are unable to reproduce it at our end. Please refer to the following sample.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/pivot-1102289041

If the problem still exists, kindly reproduce the problem in the provided sample and revert us (or) send your sample that replicating the problem. This would be helpful for us to investigate the reported problem at our end and provide the solution at the earliest.

Regards,
Manikandan

Close the issue since has not had any activity for 3 months.