GrapeCity.Xaml.SpreadSheet.UI
SaveExcelAsync(Stream,ExcelFileFormat,ExcelSaveFlags) Method
Example 


GrapeCity.Xaml.SpreadSheet.UI Namespace > GcSpreadSheet Class > SaveExcelAsync Method : SaveExcelAsync(Stream,ExcelFileFormat,ExcelSaveFlags) Method
The stream to save to.
The file format to save to.
Options for saving to a file.
Saves GcSpreadSheet to an Excel Compound Document File.
Syntax
'Declaration
 
Public Overloads Function SaveExcelAsync( _
   ByVal stream As Stream, _
   ByVal format As ExcelFileFormat, _
   ByVal saveFlags As ExcelSaveFlags _
) As IAsyncAction
'Usage
 
Dim instance As GcSpreadSheet
Dim stream As Stream
Dim format As ExcelFileFormat
Dim saveFlags As ExcelSaveFlags
Dim value As IAsyncAction
 
value = instance.SaveExcelAsync(stream, format, saveFlags)
public IAsyncAction SaveExcelAsync( 
   Stream stream,
   ExcelFileFormat format,
   ExcelSaveFlags saveFlags
)

Parameters

stream
The stream to save to.
format
The file format to save to.
saveFlags
Options for saving to a file.
Example
This example uses the SaveExcelAsync method.
private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var filePicker = new Windows.Storage.Pickers.FileSavePicker();
                filePicker.FileTypeChoices.Add("Excel Files", new List<string>() { ".xls", ".xlsx" });
                filePicker.SuggestedFileName = "New SpreadSheet File";
                Windows.Storage.StorageFile storageFile = await filePicker.PickSaveFileAsync();
                if (storageFile != null)
                {
                    using (var stream = await storageFile.OpenStreamForWriteAsync())
                    {
                        var fileName = storageFile.FileType.ToUpperInvariant();
                        
                       await gcSpreadSheet1.SaveExcelAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.ExcelFileFormat.XLSX);                       
                       //await gcSpreadSheet1.SaveExcelAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.ExcelFileFormat.XLSX, GrapeCity.Xaml.SpreadSheet.Data.ExcelSaveFlags.DataOnly);                      
                    }
                }
            }
            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.FileSavePicker()
            filePicker.FileTypeChoices.Add("Excel Files", New List(Of String)() From {".xls", ".xlsx"})
            filePicker.SuggestedFileName = "New SpreadSheet File"
            Dim storageFile As Windows.Storage.StorageFile = Await filePicker.PickSaveFileAsync()

            If storageFile IsNot Nothing Then
                Using stream = Await storageFile.OpenStreamForWriteAsync()
                    Dim fileName = storageFile.FileType.ToUpperInvariant()
                    await GcSpreadSheet1.SaveExcelAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.ExcelFileFormat.XLSX)                   
                    'await GcSpreadSheet1.SaveExcelAsync(stream, GrapeCity.Xaml.SpreadSheet.Data.ExcelFileFormat.XLSX, GrapeCity.Xaml.SpreadSheet.Data.ExcelSaveFlags.DataOnly)                    
                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