This is a migrated thread and some comments may be shown as answers.

Angular Grid Excel export - detect finish

1 Answer 72 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vince
Top achievements
Rank 1
Vince asked on 26 Aug 2020, 03:18 PM

I am using Kendo UI for Angular and trying to do a multi-grid export per the instructions given at 

https://www.telerik.com/kendo-angular-ui/components/excelexport/how-to/export-to-separate-sheets/

I would like to present a "waiting" indicator to the user until the report is actually downloaded.

The problem is that:

this.gridElements.first.kendoExcelElement.save(workbooks[0]);

returns immediately, and I don't know of a way to monitor the status of the download to detect once it has finished. Any tips for how I can detect finish?

Here is the code for the export:

  this.loaded = false;
    //Multi-export method outlined at: https://www.telerik.com/kendo-angular-ui/components/excelexport/how-to/export-to-separate-sheets/
    Promise.all(elementsWithData.map(c => c.kendoExcelElement.workbookOptions())).then((workbooks) => {
      //Set the name on the parent workbook/sheet
      workbooks.forEach((w, index) => {
        //Don't add the first workbook since that would result in duplicate sheets based on the fact
        //that the first workbook is the one being concatenated too...
        if(index > 0) {
          workbooks[0].sheets = workbooks[0].sheets.concat(w.sheets);
        }
      });
      //our problem is that this save call does not wait, and does not return a promise to hold on...
      this.gridElements.first.kendoExcelElement.save(workbooks[0]);
    }).catch(e => console.log(e))
    .finally(() => this.loaded = true);

Thanks!

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 28 Aug 2020, 06:48 AM

Hi Vince,

Implementing a Loading indicator would be ideal in this case, but notifying the user when the export operation is complete is troublesome, as we don't get enough feedback from the browser.

There are three distinct operations that make up the export:

  1. Collecting and processing the data. The excelExport is fired at the end of this task.
  2. Generating the MS Excel Document and encoding it as Base64 string. No event is fired at this stage.
  3. Saving the exported document directly in the browser or by using a server proxy. No event is fired at this stage.

The end of step 3 is ideally when we want to notify the user. Sadly, there's no browser event that we can hook to. Saving the file is an asynchronous operation that does not report back to the main thread. Maybe the server-side proxy can be extended to provide a status end-point that blocks while the request for a particular user completes. I am afraid that we don't have any specific examples to share.

Keep in mind that the maximum size of the exported file to Excel has a system-specific limit. For large data sets, it is highly recommended that you use a server-side solution.

https://www.telerik.com/kendo-angular-ui/components/grid/export/excel-export/#toc-known-limitations

Regards,
Martin
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Tags
General Discussions
Asked by
Vince
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or