Event to indicate download started and/or finished

1 Answer 651 Views
Excel Export PDF Export
Artur
Top achievements
Rank 1
Artur asked on 05 Aug 2021, 10:41 AM
After exporting the excel file, after generating the file, how can I track the file download has started and when will it end?

1 Answer, 1 is accepted

Sort by
0
Accepted
Silviya
Telerik team
answered on 09 Aug 2021, 05:42 AM

Hello Artur,

Thank you for the screenshots.

Start of download:

If I assume that the component in use is ExcelExport. Its save method could be used to indicate that the download process has been started.

https://www.telerik.com/kendo-angular-ui/components/excel-export/api/ExcelExportComponent/#toc-save

If it's PdfExport - the saveAs method would do the trick.

https://www.telerik.com/kendo-angular-ui/components/pdf-export/api/PDFExportComponent/#toc-saveas

If the Grid is used though, there is an excelExport event that could be used as a start for the download. Keep in mind that this event will be fired only when a button with kendoGridExcelCommand directive is clicked:

https://www.telerik.com/kendo-angular-ui/components/grid/api/GridComponent/#toc-excelexport

The saveAsExcel and respectively saveAsPDF methods could also serve as a start of the download process.

 

End of download:

As for when the download has been completed - that could be a bit tricky. Once the export starts and the file is ready to be further processed, then the browser handles the actual download. The Kendo components do not know when the download ends and that is why they are unable to emit an event.

However, we prepared a workaround that may be of use for the situation:

https://stackblitz.com/edit/angular-wsgplz-phzpta?file=app%2Fapp.component.ts

For further details on this approach, please take a look at the following article:

https://www.telerik.com/kendo-angular-ui-develop/components/knowledge-base/show-loading-spinner-excel-export/

Still, the demo is simply a suggestion since we use ngZone and not a particular event from our component.

Also, keep in mind that there are some known limitations of the excel export:

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

 

As a side note, after some research I found an interesting discussion that has been going on for years on detecting download completion: 

https://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download 

It may not be a perfect fit, but it could help with some brainstorming ideas.

Regards,
Silviya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Excel Export PDF Export
Asked by
Artur
Top achievements
Rank 1
Answers by
Silviya
Telerik team
Share this question
or