Hi,
I'm referencing https://www.telerik.com/kendo-angular-ui/components/excelexport/how-to/export-to-separate-sheets/ to do Excel export with *ngFor option, but the difference is that my data comes from a service instead of static client data. When calling 'this.excelExportComponents.first.save(workbooks[0]);' in the subscribe of the service call, I got below error:
core.js:6014 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'save' of undefined
TypeError: Cannot read property 'save' of undefined
at management-view.component.ts:175
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:39699)
at ZoneDelegate.invoke (zone-evergreen.js:358)
at Zone.run (zone-evergreen.js:124)
at zone-evergreen.js:855
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:39680)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at resolvePromise (zone-evergreen.js:797)
at zone-evergreen.js:862
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:39680)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:559)
at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:469)
at invokeTask (zone-evergreen.js:1603)
at XMLHttpRequest.globalZoneAwareCallback (zone-evergreen.js:1640)
I guess this.excelExportComponents.first is not ready yet in the sevice call subscribe and I should call the 'save' method at some point after the binding finished. After some experiment I ended up using a flag set to true after service call and in AfterViewChecked hook checking if the flag is true then do the concat and save, then reset the flag. This seems to work but seems not so ideal, as AfterViewChecked is quite frequently called. If there's better way do export async data?
Thanks.