GrapeCity.Xaml.SpreadSheet.UI
OpenExcelAsync(Stream,ExcelOpenFlags) Method
Example 


GrapeCity.Xaml.SpreadSheet.UI Namespace > GcSpreadSheet Class > OpenExcelAsync Method : OpenExcelAsync(Stream,ExcelOpenFlags) Method
The file stream.
The flag used to open the file.
Opens an Excel Compound Document File and loads it into GcSpreadSheet.
Syntax
'Declaration
 
Public Overloads Function OpenExcelAsync( _
   ByVal stream As Stream, _
   ByVal openFlags As ExcelOpenFlags _
) As IAsyncAction
'Usage
 
Dim instance As GcSpreadSheet
Dim stream As Stream
Dim openFlags As ExcelOpenFlags
Dim value As IAsyncAction
 
value = instance.OpenExcelAsync(stream, openFlags)
public IAsyncAction OpenExcelAsync( 
   Stream stream,
   ExcelOpenFlags openFlags
)

Parameters

stream
The file stream.
openFlags
The flag used to open the file.
Example
This example uses the OpenExcelAsync method.
private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var filePicker = new Windows.Storage.Pickers.FileOpenPicker();
                filePicker.FileTypeFilter.Add(".xls");
                filePicker.FileTypeFilter.Add(".xlsx");
                Windows.Storage.StorageFile storageFile = await filePicker.PickSingleFileAsync();
                if (storageFile != null)
                {
                    using (var stream = await storageFile.OpenStreamForReadAsync())
                    {                        
                        await gcSpreadSheet1.OpenExcelAsync(stream);
                        //await gcSpreadSheet1.OpenExcelAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.ExcelOpenFlags.RowAndColumnHeaders);                        
                    }
                }
            }
            catch (Exception ex)
            {
                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(ex.Message, "Error");
                dialog.ShowAsync();
            }                
        }
Private Async Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        Try
            Dim filePicker As New Windows.Storage.Pickers.FileOpenPicker()
            filePicker.FileTypeFilter.Add(".xls")
            filePicker.FileTypeFilter.Add(".xlsx")
            Dim storageFile As Windows.Storage.StorageFile = Await filePicker.PickSingleFileAsync()

            If storageFile IsNot Nothing Then
                Using stream = Await storageFile.OpenStreamForReadAsync()
                    await gcSpreadSheet1.OpenExcelAsync(stream)
                    'await gcSpreadSheet1.OpenExcelAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.ExcelOpenFlags.RowAndColumnHeaders)                   
                    
                End Using
            End If
        Catch ex As Exception
            Dim dialog As Windows.UI.Popups.MessageDialog = New Windows.UI.Popups.MessageDialog(ex.Message, "Error")
            dialog.ShowAsync()
        End Try
    End Sub
See Also

Reference

GcSpreadSheet Class
GcSpreadSheet Members
Overload List