Have a simple application which loads an xls file and then extracts some data. As the open method did not appear to be asynchronous and awaitable I called open and then saw the spreadsheet populated with no values being retrieved from the spreadsheet. However when a manually called method by adding to a button and clicking it populated correctly. Eventually tracked down the work workbook loaded event and putting code in there seemed to work but their was no inidcation on the method that the open was running asynchronously and perhaps the async/await pattern would be better or as an overload.
MGMohanraj Gunasekaran Syncfusion Team January 23, 2019 11:13 AM
Thanks for using Syncfusion product.
By default, Spreadsheet does not have the direct support for OpenAsync so, can you please share your Async implementation to open the .xlsx file. Also, we have prepare the sample based on your code part. If it is possible please make the changes in below attached sample to reproduce your reported scenario. It will be helpful us to provide the solution at the earliest.
Here's an example of an implemention using Async/Await to handle the asynchronicity of the spreadsheet open functionality If you look at the Form_Load you will notice that the Import (Which is simply a wrapper around existing Open method) only completes when the event is fired which sets the semaphore (TaskCompletionSource) to true.
This results in the PopulateStyles() and ApplyStyles(0) methods only getting called after the worksheet is loaded. I'm working around the existing method implementation but this should be do-able to make the open method an asynchronous method.
'//Used as a semaphore to identify when load is complete
Dim tcs As New TaskCompletionSource(Of Boolean)
Public Async Function Import(name As String) As Task
'//Can now call the Import which calls the Open event
' - only continues on when workbook is fully loaded
Private Sub Spreadsheet_WorkbookLoaded(ByVal sender As Object, ByVal args As Syncfusion.Windows.Forms.Spreadsheet.Helpers.WorkbookLoadedEventArgs)
tcs.SetResult(True) '//Sets the semaphore when workbook is loaded
MGMohanraj Gunasekaran Syncfusion Team January 24, 2019 09:16 AM
Thanks for your update.
We have planned to implemnt the OpenAsync method to handle the Spreadsheet.open functionality. So, we have logged the feature “Provide OpenAsync support to open the excel file” for this. It will be available on our next main release 2019 Volume1 which will be expected at first week of March 2019.